diff --git a/discovery/chan_series.go b/discovery/chan_series.go index eaebc0b4f..7ed9bbdef 100644 --- a/discovery/chan_series.go +++ b/discovery/chan_series.go @@ -215,7 +215,9 @@ func (c *ChanSeries) FilterKnownChanIDs(_ chainhash.Hash, isZombieChan func(time.Time, time.Time) bool) ( []lnwire.ShortChannelID, error) { - newChanIDs, err := c.graph.FilterKnownChanIDs(superSet, isZombieChan) + newChanIDs, err := c.graph.FilterKnownChanIDs( + context.TODO(), superSet, isZombieChan, + ) if err != nil { return nil, err } diff --git a/graph/db/graph.go b/graph/db/graph.go index c5213ac8d..bc3d8ee3d 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -514,10 +514,11 @@ func (c *ChannelGraph) PruneGraphNodes() error { // words, we perform a set difference of our set of chan ID's and the ones // passed in. This method can be used by callers to determine the set of // channels another peer knows of that we don't. -func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo, +func (c *ChannelGraph) FilterKnownChanIDs(ctx context.Context, + chansInfo []ChannelUpdateInfo, isZombieChan func(time.Time, time.Time) bool) ([]uint64, error) { - unknown, knownZombies, err := c.db.FilterKnownChanIDs(chansInfo) + unknown, knownZombies, err := c.db.FilterKnownChanIDs(ctx, chansInfo) if err != nil { return nil, err } @@ -547,7 +548,7 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo, // alive, and we let it be added to the set of IDs to query our // peer for. err := c.db.MarkEdgeLive( - context.TODO(), info.ShortChannelID.ToUint64(), + ctx, info.ShortChannelID.ToUint64(), ) // Since there is a chance that the edge could have been marked // as "live" between the FilterKnownChanIDs call and the diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 0f2e635cf..ff06f5046 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -2976,7 +2976,7 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) { // Call FilterKnownChanIDs with an isStillZombie call-back that would // result in the current zombies still be considered as zombies. - _, err = graph.FilterKnownChanIDs([]ChannelUpdateInfo{ + _, err = graph.FilterKnownChanIDs(ctx, []ChannelUpdateInfo{ {ShortChannelID: scid1}, {ShortChannelID: scid2}, {ShortChannelID: scid3}, @@ -2992,7 +2992,7 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) { // Now call it again but this time with a isStillZombie call-back that // would result in channel with SCID 2 no longer being considered a // zombie. - _, err = graph.FilterKnownChanIDs([]ChannelUpdateInfo{ + _, err = graph.FilterKnownChanIDs(ctx, []ChannelUpdateInfo{ {ShortChannelID: scid1}, { ShortChannelID: scid2, @@ -3038,7 +3038,9 @@ func TestFilterKnownChanIDs(t *testing.T) { {ShortChannelID: scid2}, {ShortChannelID: scid3}, } - filteredIDs, err := graph.FilterKnownChanIDs(preChanIDs, isZombieUpdate) + filteredIDs, err := graph.FilterKnownChanIDs( + ctx, preChanIDs, isZombieUpdate, + ) require.NoError(t, err, "unable to filter chan IDs") require.EqualValues(t, []uint64{ scid1.ToUint64(), @@ -3163,7 +3165,7 @@ func TestFilterKnownChanIDs(t *testing.T) { for _, queryCase := range queryCases { resp, err := graph.FilterKnownChanIDs( - queryCase.queryIDs, isZombieUpdate, + ctx, queryCase.queryIDs, isZombieUpdate, ) require.NoError(t, err) @@ -3342,7 +3344,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) { } _, err := graph.FilterKnownChanIDs( - chanIDs, + ctx, chanIDs, func(t time.Time, t2 time.Time) bool { return rand.Intn(2) == 0 }, diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index cdc6df1a6..edd93a578 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -267,8 +267,9 @@ type Store interface { //nolint:interfacebloat // callers to determine the set of channels another peer knows of that // we don't. The ChannelUpdateInfos for the known zombies is also // returned. - FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64, - []ChannelUpdateInfo, error) + FilterKnownChanIDs(ctx context.Context, + chansInfo []ChannelUpdateInfo) ([]uint64, []ChannelUpdateInfo, + error) // FilterChannelRange returns the channel ID's of all known channels // which were mined in a block height within the passed range. The diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 2db9f3918..2627e1db7 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -2679,8 +2679,8 @@ func (c *KVStore) NodeUpdatesInHorizon(_ context.Context, startTime, // passed in. This method can be used by callers to determine the set of // channels another peer knows of that we don't. The ChannelUpdateInfos for the // known zombies is also returned. -func (c *KVStore) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64, - []ChannelUpdateInfo, error) { +func (c *KVStore) FilterKnownChanIDs(_ context.Context, + chansInfo []ChannelUpdateInfo) ([]uint64, []ChannelUpdateInfo, error) { var ( newChanIDs []uint64 diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 2b72c4673..6503dc22f 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -2679,11 +2679,10 @@ func (s *SQLStore) forEachChanWithPoliciesInSCIDList(ctx context.Context, // known zombies is also returned. // // NOTE: part of the Store interface. -func (s *SQLStore) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64, - []ChannelUpdateInfo, error) { +func (s *SQLStore) FilterKnownChanIDs(ctx context.Context, + chansInfo []ChannelUpdateInfo) ([]uint64, []ChannelUpdateInfo, error) { var ( - ctx = context.TODO() newChanIDs []uint64 knownZombies []ChannelUpdateInfo infoLookup = make(