graph/db: thread context through NumZombies

This commit is contained in:
Elle Mouton committed 2026-02-25 15:33:34 +02:00
1 parent f98905ae99
commit 37cc6b29d9
6 files changed
+7 -8

No files matched your search

+2 -2
View File
@@ -761,8 +761,8 @@ func (c *ChannelGraph) IsZombieEdge(ctx context.Context,
} }
// NumZombies returns the current number of zombie channels in the graph. // NumZombies returns the current number of zombie channels in the graph.
func (c *ChannelGraph) NumZombies() (uint64, error) { func (c *ChannelGraph) NumZombies(ctx context.Context) (uint64, error) {
return c.db.NumZombies() return c.db.NumZombies(ctx)
} }
// PutClosedScid stores a SCID for a closed channel in the database. // PutClosedScid stores a SCID for a closed channel in the database.
+1 -1
View File
@@ -4535,7 +4535,7 @@ func putSerializedPolicy(t *testing.T, db kvdb.Backend, from []byte,
func assertNumZombies(t *testing.T, graph *ChannelGraph, expZombies uint64) { func assertNumZombies(t *testing.T, graph *ChannelGraph, expZombies uint64) {
t.Helper() t.Helper()
numZombies, err := graph.NumZombies() numZombies, err := graph.NumZombies(t.Context())
require.NoError(t, err, "unable to query number of zombies") require.NoError(t, err, "unable to query number of zombies")
require.Equal(t, expZombies, numZombies) require.Equal(t, expZombies, numZombies)
} }
+1 -1
View File
@@ -339,7 +339,7 @@ type Store interface { //nolint:interfacebloat
// NumZombies returns the current number of zombie channels in the // NumZombies returns the current number of zombie channels in the
// graph. // graph.
NumZombies() (uint64, error) NumZombies(ctx context.Context) (uint64, error)
// PutClosedScid stores a SCID for a closed channel in the database. // PutClosedScid stores a SCID for a closed channel in the database.
// This is so that we can ignore channel announcements that we know to // This is so that we can ignore channel announcements that we know to
+1 -1
View File
@@ -4405,7 +4405,7 @@ func isZombieEdge(zombieIndex kvdb.RBucket,
} }
// NumZombies returns the current number of zombie channels in the graph. // 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 var numZombies uint64
err := kvdb.View(c.db, func(tx kvdb.RTx) error { err := kvdb.View(c.db, func(tx kvdb.RTx) error {
edges := tx.ReadBucket(edgeBucket) edges := tx.ReadBucket(edgeBucket)
+1 -2
View File
@@ -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. // NumZombies returns the current number of zombie channels in the graph.
// //
// NOTE: part of the Store interface. // NOTE: part of the Store interface.
func (s *SQLStore) NumZombies() (uint64, error) { func (s *SQLStore) NumZombies(ctx context.Context) (uint64, error) {
var ( var (
ctx = context.TODO()
numZombies uint64 numZombies uint64
) )
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error { err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
+1 -1
View File
@@ -7376,7 +7376,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context,
} }
// Query the graph for the current number of zombie channels. // Query the graph for the current number of zombie channels.
numZombies, err := graph.NumZombies() numZombies, err := graph.NumZombies(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }