graph/db: thread context through FetchChannelEdgesByID

This commit is contained in:
Elle Mouton committed 2026-02-25 16:11:25 +02:00
1 parent acdef84d30
commit 6bbb9a32fc
14 files changed
+93 -42

No files matched your search

+20 -5
View File
@@ -522,8 +522,16 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
//nolint:ll
paths, err := blindedpath.BuildBlindedPaymentPaths(
&blindedpath.BuildBlindedPathCfg{
FindRoutes: cfg.QueryBlindedRoutes,
FetchChannelEdgesByID: cfg.Graph.FetchChannelEdgesByID,
FindRoutes: cfg.QueryBlindedRoutes,
FetchChannelEdgesByID: func(chanID uint64) (
*models.ChannelEdgeInfo,
*models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error) {
return cfg.Graph.FetchChannelEdgesByID(
context.TODO(), chanID,
)
},
FetchOurOpenChannels: cfg.ChanDB.FetchAllOpenChannels,
PathID: paymentAddr[:],
ValueMsat: invoice.Value,
@@ -790,9 +798,16 @@ func newSelectHopHintsCfg(invoicesCfg *AddInvoiceConfig,
FetchAllChannels: invoicesCfg.ChanDB.FetchAllChannels,
IsChannelActive: invoicesCfg.IsChannelActive,
IsPublicNode: invoicesCfg.Graph.IsPublicNode,
FetchChannelEdgesByID: invoicesCfg.Graph.FetchChannelEdgesByID,
GetAlias: invoicesCfg.GetAlias,
MaxHopHints: maxHopHints,
FetchChannelEdgesByID: func(chanID uint64) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error) {
return invoicesCfg.Graph.FetchChannelEdgesByID(
context.TODO(), chanID,
)
},
GetAlias: invoicesCfg.GetAlias,
MaxHopHints: maxHopHints,
}
}
+5 -2
View File
@@ -1,6 +1,8 @@
package invoicesrpc
import (
"context"
"github.com/lightningnetwork/lnd/graph/db/models"
)
@@ -9,8 +11,9 @@ type GraphSource interface {
// FetchChannelEdgesByID attempts to look up the two directed edges for
// the channel identified by the channel ID. If the channel can't be
// found, then graphdb.ErrEdgeNotFound is returned.
FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo,
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)
FetchChannelEdgesByID(ctx context.Context, chanID uint64) (
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
*models.ChannelEdgePolicy, error)
// IsPublicNode is a helper method that determines whether the node with
// the given public key is seen as a public node in the graph from the