diff --git a/graph/builder.go b/graph/builder.go index 5100066a3..eec97b37b 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -574,7 +574,7 @@ func (b *Builder) pruneZombieChans() error { // the channel being closed and can prune it from our graph. if b.cfg.AssumeChannelValid { disabledChanIDs, err := b.cfg.Graph.DisabledChannelIDs( - lnwire.GossipVersion1, + context.TODO(), lnwire.GossipVersion1, ) if err != nil { return fmt.Errorf("unable to get disabled channels "+ diff --git a/graph/db/graph.go b/graph/db/graph.go index ba63941a8..acafbcc68 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -662,10 +662,11 @@ func (c *ChannelGraph) ForEachChannel(ctx context.Context, } // DisabledChannelIDs returns the channel ids of disabled channels. -func (c *ChannelGraph) DisabledChannelIDs(v lnwire.GossipVersion) ( +func (c *ChannelGraph) DisabledChannelIDs(ctx context.Context, + v lnwire.GossipVersion) ( []uint64, error) { - return c.db.DisabledChannelIDs(v) + return c.db.DisabledChannelIDs(ctx, v) } // HasV1ChannelEdge returns true if the database knows of a channel edge. @@ -952,8 +953,10 @@ func (c *VersionedGraph) ForEachChannelCacheable( } // DisabledChannelIDs returns the channel ids of disabled channels. -func (c *VersionedGraph) DisabledChannelIDs() ([]uint64, error) { - return c.db.DisabledChannelIDs(c.v) +func (c *VersionedGraph) DisabledChannelIDs( + ctx context.Context) ([]uint64, error) { + + return c.db.DisabledChannelIDs(ctx, c.v) } // FetchChanInfos returns the set of channel edges for the passed channel IDs. diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 051f59a6d..737376b1a 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -4359,7 +4359,7 @@ func testDisabledChannelIDs(t *testing.T, v lnwire.GossipVersion) { require.NoError(t, graph.AddChannelEdge(ctx, edgeInfo)) // Ensure no disabled channels exist in the bucket on start. - disabledChanIds, err := graph.DisabledChannelIDs() + disabledChanIds, err := graph.DisabledChannelIDs(ctx) require.NoError(t, err, "unable to get disabled channel ids") require.Empty(t, disabledChanIds) @@ -4372,7 +4372,7 @@ func testDisabledChannelIDs(t *testing.T, v lnwire.GossipVersion) { edge1.DisableFlags |= lnwire.ChanUpdateDisableIncoming } require.NoError(t, graph.UpdateEdgePolicy(ctx, edge1)) - disabledChanIds, err = graph.DisabledChannelIDs() + disabledChanIds, err = graph.DisabledChannelIDs(ctx) require.NoError(t, err, "unable to get disabled channel ids") require.Empty(t, disabledChanIds) @@ -4385,7 +4385,7 @@ func testDisabledChannelIDs(t *testing.T, v lnwire.GossipVersion) { edge2.DisableFlags |= lnwire.ChanUpdateDisableIncoming } require.NoError(t, graph.UpdateEdgePolicy(ctx, edge2)) - disabledChanIds, err = graph.DisabledChannelIDs() + disabledChanIds, err = graph.DisabledChannelIDs(ctx) require.NoError(t, err, "unable to get disabled channel ids") require.Equal(t, []uint64{edgeInfo.ChannelID}, disabledChanIds) @@ -4394,7 +4394,7 @@ func testDisabledChannelIDs(t *testing.T, v lnwire.GossipVersion) { require.NoError(t, graph.DeleteChannelEdges( false, true, edgeInfo.ChannelID, )) - disabledChanIds, err = graph.DisabledChannelIDs() + disabledChanIds, err = graph.DisabledChannelIDs(ctx) require.NoError(t, err, "unable to get disabled channel ids") require.Empty(t, disabledChanIds) } diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index 9daabb0c6..897b56aa7 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -191,7 +191,8 @@ type Store interface { //nolint:interfacebloat // DisabledChannelIDs returns the channel ids of disabled channels. // A channel is disabled when two of the associated ChanelEdgePolicies // have their disabled bit on. - DisabledChannelIDs(v lnwire.GossipVersion) ([]uint64, error) + DisabledChannelIDs(ctx context.Context, + v lnwire.GossipVersion) ([]uint64, error) // AddChannelEdge adds a new (undirected, blank) edge to the graph // database. An undirected edge from the two target nodes are created. diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 67cebc280..ceb2b673e 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -773,7 +773,7 @@ func (c *KVStore) ForEachNodeCached(ctx context.Context, withAddrs bool, // A channel is disabled when two of the associated ChanelEdgePolicies // have their disabled bit on. func (c *KVStore) DisabledChannelIDs( - v lnwire.GossipVersion) ([]uint64, error) { + _ context.Context, v lnwire.GossipVersion) ([]uint64, error) { if v != lnwire.GossipVersion1 { return nil, ErrVersionNotSupportedForKVDB diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index cc058c8b0..77863d71f 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -460,10 +460,9 @@ func (s *SQLStore) FetchNodeFeatures(ctx context.Context, // // NOTE: part of the Store interface. func (s *SQLStore) DisabledChannelIDs( - v lnwire.GossipVersion) ([]uint64, error) { + ctx context.Context, v lnwire.GossipVersion) ([]uint64, error) { var ( - ctx = context.TODO() chanIDs []uint64 ) err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {