graph/db: thread context through IsZombieEdge
What changed, and why it matters
This commit is a routine code cleanup: it threads a standard Go context.Context parameter through the IsZombieEdge function and its callers. The context allows callers to pass cancellation/timeout information into the SQL store implementation, replacing a placeholder TODO context. There is no security-relevant behavior change visible in the diff.
No security action required; treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change updates the IsZombieEdge method signature across ChannelGraph, VersionedGraph, the Store interface, KVStore, and SQLStore to accept a context.Context. The SQL implementation replaces context.TODO() with the supplied ctx; the KV implementation ignores the context with _. Test call sites are updated accordingly. No logic changes, no new validation, no privilege/credential changes, and no disclosed vulnerability fix.
Changed components
graph/db/graph.gograph/db/graph_test.gograph/db/interfaces.gograph/db/kv_store.gograph/db/sql_store.goInspect captured patch +20 / −17
diff --git a/graph/db/graph.go b/graph/db/graph.go
index b4a811a..b02ef79 100644
--- a/graph/db/graph.go
+++ b/graph/db/graph.go
@@ -754,10 +754,10 @@ func (c *ChannelGraph) ChannelView() ([]EdgePoint, error) {
}
// IsZombieEdge returns whether the edge is considered zombie.
-func (c *ChannelGraph) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte,
- error) {
+func (c *ChannelGraph) IsZombieEdge(ctx context.Context,
+ chanID uint64) (bool, [33]byte, [33]byte, error) {
- return c.db.IsZombieEdge(lnwire.GossipVersion1, chanID)
+ return c.db.IsZombieEdge(ctx, lnwire.GossipVersion1, chanID)
}
// NumZombies returns the current number of zombie channels in the graph.
@@ -829,10 +829,10 @@ func (c *VersionedGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
}
// IsZombieEdge returns whether the edge is considered zombie for this version.
-func (c *VersionedGraph) IsZombieEdge(chanID uint64) (bool, [33]byte,
- [33]byte, error) {
+func (c *VersionedGraph) IsZombieEdge(ctx context.Context,
+ chanID uint64) (bool, [33]byte, [33]byte, error) {
- return c.db.IsZombieEdge(c.v, chanID)
+ return c.db.IsZombieEdge(ctx, c.v, chanID)
}
// AddrsForNode returns all known addresses for the target node public key.
diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go
index 7e7712b..79a1542 100644
--- a/graph/db/graph_test.go
+++ b/graph/db/graph_test.go
@@ -714,7 +714,7 @@ func testEdgeInsertionDeletion(t *testing.T, v lnwire.GossipVersion) {
require.ErrorIs(t, err, ErrZombieEdge)
require.NotNil(t, edge)
- isZombie, _, _, err := graph.IsZombieEdge(chanID)
+ isZombie, _, _, err := graph.IsZombieEdge(ctx, chanID)
require.NoError(t, err)
require.True(t, isZombie)
@@ -2940,7 +2940,9 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) {
)
isZombie := func(scid lnwire.ShortChannelID) bool {
- zombie, _, _, err := graph.IsZombieEdge(scid.ToUint64())
+ zombie, _, _, err := graph.IsZombieEdge(
+ ctx, scid.ToUint64(),
+ )
require.NoError(t, err)
return zombie
@@ -4562,7 +4564,7 @@ func TestGraphZombieIndex(t *testing.T) {
// Since the edge is known the graph and it isn't a zombie, IsZombieEdge
// should not report the channel as a zombie.
- isZombie, _, _, err := graph.IsZombieEdge(edge.ChannelID)
+ isZombie, _, _, err := graph.IsZombieEdge(ctx, edge.ChannelID)
require.NoError(t, err)
require.False(t, isZombie)
assertNumZombies(t, graph, 0)
@@ -4571,7 +4573,9 @@ func TestGraphZombieIndex(t *testing.T) {
// to see it within the index.
err = graph.DeleteChannelEdges(false, true, edge.ChannelID)
require.NoError(t, err, "unable to mark edge as zombie")
- isZombie, pubKey1, pubKey2, err := graph.IsZombieEdge(edge.ChannelID)
+ isZombie, pubKey1, pubKey2, err := graph.IsZombieEdge(
+ ctx, edge.ChannelID,
+ )
require.NoError(t, err)
require.True(t, isZombie)
require.Equal(t, node1.PubKeyBytes, pubKey1)
@@ -4589,7 +4593,7 @@ func TestGraphZombieIndex(t *testing.T) {
ErrZombieEdgeNotFound,
)
- isZombie, _, _, err = graph.IsZombieEdge(edge.ChannelID)
+ isZombie, _, _, err = graph.IsZombieEdge(ctx, edge.ChannelID)
require.NoError(t, err)
require.False(t, isZombie)
@@ -4602,7 +4606,7 @@ func TestGraphZombieIndex(t *testing.T) {
)
require.NoError(t, err, "unable to mark edge as zombie")
- isZombie, _, _, err = graph.IsZombieEdge(edge.ChannelID)
+ isZombie, _, _, err = graph.IsZombieEdge(ctx, edge.ChannelID)
require.NoError(t, err)
require.True(t, isZombie)
assertNumZombies(t, graph, 1)
diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go
index 6a6d6b8..2540ca1 100644
--- a/graph/db/interfaces.go
+++ b/graph/db/interfaces.go
@@ -334,8 +334,8 @@ type Store interface { //nolint:interfacebloat
// IsZombieEdge returns whether the edge is considered zombie. If it is
// a zombie, then the two node public keys corresponding to this edge
// are also returned.
- IsZombieEdge(v lnwire.GossipVersion, chanID uint64) (bool, [33]byte,
- [33]byte, error)
+ IsZombieEdge(ctx context.Context, v lnwire.GossipVersion,
+ chanID uint64) (bool, [33]byte, [33]byte, error)
// NumZombies returns the current number of zombie channels in the
// graph.
diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go
index beda595..abf0111 100644
--- a/graph/db/kv_store.go
+++ b/graph/db/kv_store.go
@@ -4344,7 +4344,7 @@ func (c *KVStore) markEdgeLiveUnsafe(tx kvdb.RwTx, chanID uint64) error {
// IsZombieEdge returns whether the edge is considered zombie. If it is a
// zombie, then the two node public keys corresponding to this edge are also
// returned.
-func (c *KVStore) IsZombieEdge(v lnwire.GossipVersion,
+func (c *KVStore) IsZombieEdge(_ context.Context, v lnwire.GossipVersion,
chanID uint64) (bool, [33]byte, [33]byte, error) {
var (
diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go
index db900f9..86a0c71 100644
--- a/graph/db/sql_store.go
+++ b/graph/db/sql_store.go
@@ -1865,11 +1865,10 @@ func (s *SQLStore) MarkEdgeLive(ctx context.Context, chanID uint64) error {
// returned.
//
// NOTE: part of the Store interface.
-func (s *SQLStore) IsZombieEdge(v lnwire.GossipVersion,
+func (s *SQLStore) IsZombieEdge(ctx context.Context, v lnwire.GossipVersion,
chanID uint64) (bool, [33]byte, [33]byte, error) {
var (
- ctx = context.TODO()
isZombie bool
pubKey1, pubKey2 route.Vertex
chanIDB = channelIDToBytes(chanID)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.