invoicesrpc: remove direct access to ChannelGraph pointer

This commit is contained in:
Elle Mouton committed 2025-02-13 11:45:09 +02:00
1 parent 9c2c95d46f
commit da43541c63
6 files changed
+30 -11

No files matched your search

+3 -3
View File
@@ -18,7 +18,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/lntypes"
@@ -75,8 +74,9 @@ type AddInvoiceConfig struct {
// channel graph.
ChanDB *channeldb.ChannelStateDB
// Graph holds a reference to the ChannelGraph database.
Graph *graphdb.ChannelGraph
// Graph gives the invoice server access to various graph related
// queries.
Graph GraphSource
// GenInvoiceFeatures returns a feature containing feature bits that
// should be advertised on freshly generated invoices.
+3 -4
View File
@@ -6,7 +6,6 @@ package invoicesrpc
import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/lightningnetwork/lnd/channeldb"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/macaroons"
@@ -52,9 +51,9 @@ type Config struct {
// specified.
DefaultCLTVExpiry uint32
// GraphDB is a global database instance which is needed to access the
// channel graph.
GraphDB *graphdb.ChannelGraph
// Graph provides the invoices with information about the current LN
// graph.
Graph GraphSource
// ChanStateDB is a possibly replicated db instance which contains the
// channel state
+19
View File
@@ -0,0 +1,19 @@
package invoicesrpc
import (
"github.com/lightningnetwork/lnd/graph/db/models"
)
// GraphSource defines the graph interface required by the invoice rpc server.
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)
// 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
// graph's source node's point of view.
IsPublicNode(pubKey [33]byte) (bool, error)
}
+1 -1
View File
@@ -346,7 +346,7 @@ func (s *Server) AddHoldInvoice(ctx context.Context,
NodeSigner: s.cfg.NodeSigner,
DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry,
ChanDB: s.cfg.ChanStateDB,
Graph: s.cfg.GraphDB,
Graph: s.cfg.Graph,
GenInvoiceFeatures: s.cfg.GenInvoiceFeatures,
GenAmpInvoiceFeatures: s.cfg.GenAmpInvoiceFeatures,
GetAlias: s.cfg.GetAlias,