From 37cc6b29d9fc1073dc796cbae0038611aeadd14f Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 25 Feb 2026 09:47:56 +0200 Subject: [PATCH] graph/db: thread context through NumZombies --- graph/db/graph.go | 4 ++-- graph/db/graph_test.go | 2 +- graph/db/interfaces.go | 2 +- graph/db/kv_store.go | 2 +- graph/db/sql_store.go | 3 +-- rpcserver.go | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/graph/db/graph.go b/graph/db/graph.go index b02ef7944..8abca8236 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -761,8 +761,8 @@ func (c *ChannelGraph) IsZombieEdge(ctx context.Context, } // NumZombies returns the current number of zombie channels in the graph. -func (c *ChannelGraph) NumZombies() (uint64, error) { - return c.db.NumZombies() +func (c *ChannelGraph) NumZombies(ctx context.Context) (uint64, error) { + return c.db.NumZombies(ctx) } // PutClosedScid stores a SCID for a closed channel in the database. diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 79a1542c3..2503f5870 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -4535,7 +4535,7 @@ func putSerializedPolicy(t *testing.T, db kvdb.Backend, from []byte, func assertNumZombies(t *testing.T, graph *ChannelGraph, expZombies uint64) { t.Helper() - numZombies, err := graph.NumZombies() + numZombies, err := graph.NumZombies(t.Context()) require.NoError(t, err, "unable to query number of zombies") require.Equal(t, expZombies, numZombies) } diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index 2540ca1b0..a42836f69 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -339,7 +339,7 @@ type Store interface { //nolint:interfacebloat // NumZombies returns the current number of zombie channels in the // graph. - NumZombies() (uint64, error) + NumZombies(ctx context.Context) (uint64, error) // PutClosedScid stores a SCID for a closed channel in the database. // This is so that we can ignore channel announcements that we know to diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index abf0111e7..98308ae4a 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -4405,7 +4405,7 @@ func isZombieEdge(zombieIndex kvdb.RBucket, } // NumZombies returns the current number of zombie channels in the graph. -func (c *KVStore) NumZombies() (uint64, error) { +func (c *KVStore) NumZombies(_ context.Context) (uint64, error) { var numZombies uint64 err := kvdb.View(c.db, func(tx kvdb.RTx) error { edges := tx.ReadBucket(edgeBucket) diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 86a0c7192..dc8492e78 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -1912,9 +1912,8 @@ func (s *SQLStore) IsZombieEdge(ctx context.Context, v lnwire.GossipVersion, // NumZombies returns the current number of zombie channels in the graph. // // NOTE: part of the Store interface. -func (s *SQLStore) NumZombies() (uint64, error) { +func (s *SQLStore) NumZombies(ctx context.Context) (uint64, error) { var ( - ctx = context.TODO() numZombies uint64 ) err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { diff --git a/rpcserver.go b/rpcserver.go index 8cbeb743b..f0eecd4a1 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -7376,7 +7376,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context, } // Query the graph for the current number of zombie channels. - numZombies, err := graph.NumZombies() + numZombies, err := graph.NumZombies(ctx) if err != nil { return nil, err }