From f98905ae990eebf2d75d3f713c18db202097d3e4 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 25 Feb 2026 09:45:03 +0200 Subject: [PATCH] graph/db: thread context through IsZombieEdge --- graph/db/graph.go | 12 ++++++------ graph/db/graph_test.go | 16 ++++++++++------ graph/db/interfaces.go | 4 ++-- graph/db/kv_store.go | 2 +- graph/db/sql_store.go | 3 +-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/graph/db/graph.go b/graph/db/graph.go index b4a811a7e..b02ef7944 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 7e7712be1..79a1542c3 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 6a6d6b8b8..2540ca1b0 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 beda595df..abf0111e7 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 db900f926..86a0c7192 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)