graph/db: thread context through to HighestChanID

This commit is contained in:
Elle Mouton committed 2025-06-19 14:49:32 +02:00
1 parent 004440a86c
commit 9597f01ce3
7 files changed
+21 -14

No files matched your search

+7 -3
View File
@@ -1,6 +1,7 @@
package discovery
import (
"context"
"time"
"github.com/btcsuite/btcd/chaincfg/chainhash"
@@ -22,7 +23,8 @@ type ChannelGraphTimeSeries interface {
// height that's close to the current tip of the main chain as we
// know it. We'll use this to start our QueryChannelRange dance with
// the remote node.
HighestChanID(chain chainhash.Hash) (*lnwire.ShortChannelID, error)
HighestChanID(ctx context.Context,
chain chainhash.Hash) (*lnwire.ShortChannelID, error)
// UpdatesInHorizon returns all known channel and node updates with an
// update timestamp between the start time and end time. We'll use this
@@ -87,8 +89,10 @@ func NewChanSeries(graph *graphdb.ChannelGraph) *ChanSeries {
// this to start our QueryChannelRange dance with the remote node.
//
// NOTE: This is part of the ChannelGraphTimeSeries interface.
func (c *ChanSeries) HighestChanID(chain chainhash.Hash) (*lnwire.ShortChannelID, error) {
chanID, err := c.graph.HighestChanID()
func (c *ChanSeries) HighestChanID(ctx context.Context,
_ chainhash.Hash) (*lnwire.ShortChannelID, error) {
chanID, err := c.graph.HighestChanID(ctx)
if err != nil {
return nil, err
}
+4 -2
View File
@@ -965,12 +965,14 @@ func (g *GossipSyncer) processChanRangeReply(_ context.Context,
// party when we're kicking off the channel graph synchronization upon
// connection. The historicalQuery boolean can be used to generate a query from
// the genesis block of the chain.
func (g *GossipSyncer) genChanRangeQuery(_ context.Context,
func (g *GossipSyncer) genChanRangeQuery(ctx context.Context,
historicalQuery bool) (*lnwire.QueryChannelRange, error) {
// First, we'll query our channel graph time series for its highest
// known channel ID.
newestChan, err := g.cfg.channelSeries.HighestChanID(g.cfg.chainHash)
newestChan, err := g.cfg.channelSeries.HighestChanID(
ctx, g.cfg.chainHash,
)
if err != nil {
return nil, err
}
+4 -1
View File
@@ -79,9 +79,12 @@ func newMockChannelGraphTimeSeries(
}
}
func (m *mockChannelGraphTimeSeries) HighestChanID(chain chainhash.Hash) (*lnwire.ShortChannelID, error) {
func (m *mockChannelGraphTimeSeries) HighestChanID(_ context.Context,
_ chainhash.Hash) (*lnwire.ShortChannelID, error) {
return &m.highestID, nil
}
func (m *mockChannelGraphTimeSeries) UpdatesInHorizon(chain chainhash.Hash,
startTime time.Time, endTime time.Time) ([]lnwire.Message, error) {