graphdb: pass context to FetchChanInfos

This commit is contained in:
Elle Mouton committed 2026-02-25 16:11:46 +02:00
1 parent f62ea62cfe
commit 46d37a691f
7 files changed
+14 -15

No files matched your search

+1 -1
View File
@@ -261,7 +261,7 @@ func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash,
chanIDs = append(chanIDs, chanID.ToUint64())
}
channels, err := c.graph.FetchChanInfos(chanIDs)
channels, err := c.graph.FetchChanInfos(context.TODO(), chanIDs)
if err != nil {
return nil, err
}
+1 -1
View File
@@ -582,7 +582,7 @@ func (b *Builder) pruneZombieChans() error {
}
disabledEdges, err := b.v1Graph.FetchChanInfos(
disabledChanIDs,
context.TODO(), disabledChanIDs,
)
if err != nil {
return fmt.Errorf("unable to fetch disabled channels "+
+7 -7
View File
@@ -353,7 +353,7 @@ func (c *ChannelGraph) MarkEdgeLive(ctx context.Context, chanID uint64) error {
// We need to add the channel back into our graph cache,
// otherwise we won't use it for path finding.
infos, err := c.db.FetchChanInfos(
lnwire.GossipVersion1, []uint64{chanID},
ctx, lnwire.GossipVersion1, []uint64{chanID},
)
if err != nil {
return err
@@ -723,10 +723,10 @@ func (c *ChannelGraph) FilterChannelRange(ctx context.Context,
}
// FetchChanInfos returns the set of channel edges for the passed channel IDs.
func (c *ChannelGraph) FetchChanInfos(v lnwire.GossipVersion,
chanIDs []uint64) ([]ChannelEdge, error) {
func (c *ChannelGraph) FetchChanInfos(ctx context.Context,
v lnwire.GossipVersion, chanIDs []uint64) ([]ChannelEdge, error) {
return c.db.FetchChanInfos(v, chanIDs)
return c.db.FetchChanInfos(ctx, v, chanIDs)
}
// FetchChannelEdgesByOutpoint attempts to lookup directed edges by funding
@@ -976,10 +976,10 @@ func (c *VersionedGraph) DisabledChannelIDs(
}
// FetchChanInfos returns the set of channel edges for the passed channel IDs.
func (c *VersionedGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge,
error) {
func (c *VersionedGraph) FetchChanInfos(ctx context.Context,
chanIDs []uint64) ([]ChannelEdge, error) {
return c.db.FetchChanInfos(c.v, chanIDs)
return c.db.FetchChanInfos(ctx, c.v, chanIDs)
}
// HighestChanID returns the "highest" known channel ID in the channel graph.
+1 -1
View File
@@ -3785,7 +3785,7 @@ func testFetchChanInfos(t *testing.T, v lnwire.GossipVersion) {
// We'll now attempt to query for the range of channel ID's we just
// inserted into the database. We should get the exact same set of
// edges back.
resp, err := graph.FetchChanInfos(edgeQuery)
resp, err := graph.FetchChanInfos(ctx, edgeQuery)
require.NoError(t, err, "unable to fetch chan edges")
require.Len(t, resp, len(edges))
+1 -1
View File
@@ -288,7 +288,7 @@ type Store interface { //nolint:interfacebloat
// edges that exist at the time of the query. This can be used to
// respond to peer queries that are seeking to fill in gaps in their
// view of the channel graph.
FetchChanInfos(v lnwire.GossipVersion,
FetchChanInfos(ctx context.Context, v lnwire.GossipVersion,
chanIDs []uint64) ([]ChannelEdge, error)
// FetchChannelEdgesByOutpoint attempts to lookup the two directed edges
+1 -1
View File
@@ -2963,7 +2963,7 @@ func (c *KVStore) FilterChannelRange(_ context.Context, startHeight,
// skipped and the result will contain only those edges that exist at the time
// of the query. This can be used to respond to peer queries that are seeking to
// fill in gaps in their view of the channel graph.
func (c *KVStore) FetchChanInfos(v lnwire.GossipVersion,
func (c *KVStore) FetchChanInfos(_ context.Context, v lnwire.GossipVersion,
chanIDs []uint64) ([]ChannelEdge, error) {
if v != lnwire.GossipVersion1 {
+2 -3
View File
@@ -2580,11 +2580,10 @@ func (s *SQLStore) IsPublicNode(ctx context.Context, v lnwire.GossipVersion,
// fill in gaps in their view of the channel graph.
//
// NOTE: part of the Store interface.
func (s *SQLStore) FetchChanInfos(v lnwire.GossipVersion,
chanIDs []uint64) ([]ChannelEdge, error) {
func (s *SQLStore) FetchChanInfos(ctx context.Context,
v lnwire.GossipVersion, chanIDs []uint64) ([]ChannelEdge, error) {
var (
ctx = context.TODO()
edges = make(map[uint64]ChannelEdge)
)
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {