From bb38aa8922ae67b5f5f34edf3cb2c0f2fdfe390c Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 25 Feb 2026 09:39:25 +0200 Subject: [PATCH] graph/db: thread context through FilterChannelRange --- discovery/chan_series.go | 2 +- graph/db/graph.go | 9 ++++++--- graph/db/graph_test.go | 6 +++--- graph/db/interfaces.go | 5 +++-- graph/db/kv_store.go | 2 +- graph/db/sql_store.go | 5 ++--- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/discovery/chan_series.go b/discovery/chan_series.go index 75654a6ea..a1f0778e2 100644 --- a/discovery/chan_series.go +++ b/discovery/chan_series.go @@ -241,7 +241,7 @@ func (c *ChanSeries) FilterChannelRange(_ chainhash.Hash, startHeight, error) { return c.graph.FilterChannelRange( - startHeight, endHeight, withTimestamps, + context.TODO(), startHeight, endHeight, withTimestamps, ) } diff --git a/graph/db/graph.go b/graph/db/graph.go index a5e79a688..bd4cfdc85 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -711,10 +711,13 @@ func (c *ChannelGraph) ChanUpdatesInHorizon(ctx context.Context, } // FilterChannelRange returns channel IDs within the passed block height range. -func (c *ChannelGraph) FilterChannelRange(startHeight, endHeight uint32, - withTimestamps bool) ([]BlockChannelRange, error) { +func (c *ChannelGraph) FilterChannelRange(ctx context.Context, + startHeight, endHeight uint32, withTimestamps bool) ( + []BlockChannelRange, error) { - return c.db.FilterChannelRange(startHeight, endHeight, withTimestamps) + return c.db.FilterChannelRange( + ctx, startHeight, endHeight, withTimestamps, + ) } // 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 9c017aafd..042ed7881 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -3477,7 +3477,7 @@ func TestFilterChannelRange(t *testing.T) { // If we try to filter a channel range before we have any channels // inserted, we should get an empty slice of results. - resp, err := graph.FilterChannelRange(10, 100, false) + resp, err := graph.FilterChannelRange(ctx, 10, 100, false) require.NoError(t, err) require.Empty(t, resp) @@ -3652,7 +3652,7 @@ func TestFilterChannelRange(t *testing.T) { // First, do the query without requesting timestamps. resp, err := graph.FilterChannelRange( - test.startHeight, test.endHeight, false, + ctx, test.startHeight, test.endHeight, false, ) require.NoError(t, err) @@ -3666,7 +3666,7 @@ func TestFilterChannelRange(t *testing.T) { // Now, query the timestamps as well. resp, err = graph.FilterChannelRange( - test.startHeight, test.endHeight, true, + ctx, test.startHeight, test.endHeight, true, ) require.NoError(t, err) diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index f443953d1..db2e511f5 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -277,8 +277,9 @@ type Store interface { //nolint:interfacebloat // offline. If withTimestamps is true then the timestamp info of the // latest received channel update messages of the channel will be // included in the response. - FilterChannelRange(startHeight, endHeight uint32, withTimestamps bool) ( - []BlockChannelRange, error) + FilterChannelRange(ctx context.Context, startHeight, + endHeight uint32, + withTimestamps bool) ([]BlockChannelRange, error) // FetchChanInfos returns the set of channel edges that correspond to // the passed channel ID's. If an edge is the query is unknown to the diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 94993c280..2a8334dca 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -2817,7 +2817,7 @@ type BlockChannelRange struct { // up after a period of time offline. If withTimestamps is true then the // timestamp info of the latest received channel update messages of the channel // will be included in the response. -func (c *KVStore) FilterChannelRange(startHeight, +func (c *KVStore) FilterChannelRange(_ context.Context, startHeight, endHeight uint32, withTimestamps bool) ([]BlockChannelRange, error) { startChanID := &lnwire.ShortChannelID{ diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 745dff55a..1b2f28635 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -1664,11 +1664,10 @@ func (s *SQLStore) ForEachChannel(ctx context.Context, // will be included in the response. // // NOTE: This is part of the Store interface. -func (s *SQLStore) FilterChannelRange(startHeight, endHeight uint32, - withTimestamps bool) ([]BlockChannelRange, error) { +func (s *SQLStore) FilterChannelRange(ctx context.Context, startHeight, + endHeight uint32, withTimestamps bool) ([]BlockChannelRange, error) { var ( - ctx = context.TODO() startSCID = &lnwire.ShortChannelID{ BlockHeight: startHeight, }