Skip to content

Commit da43541

Browse files
committed
invoicesrpc: remove direct access to ChannelGraph pointer
1 parent 9c2c95d commit da43541

File tree

6 files changed

+30
-11
lines changed

6 files changed

+30
-11
lines changed

Diff for: docs/release-notes/release-notes-0.19.0.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,9 @@ config option](https://github.com/lightningnetwork/lnd/pull/9182) and introduce
245245
a new option `channel-max-fee-exposure` which is unambiguous in its description.
246246
The underlying functionality between those two options remain the same.
247247

248-
* [Abstraction of graph](https://github.com/lightningnetwork/lnd/pull/9480)
249-
access for autopilot.
248+
* Graph abstraction work:
249+
- [Abstract autopilot access](https://github.com/lightningnetwork/lnd/pull/9480)
250+
- [Abstract invoicerpc server access](https://github.com/lightningnetwork/lnd/pull/9516)
250251

251252
* [Golang was updated to
252253
`v1.22.11`](https://github.com/lightningnetwork/lnd/pull/9462).

Diff for: lnrpc/invoicesrpc/addinvoice.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/btcsuite/btcd/chaincfg/chainhash"
1919
"github.com/btcsuite/btcd/wire"
2020
"github.com/lightningnetwork/lnd/channeldb"
21-
graphdb "github.com/lightningnetwork/lnd/graph/db"
2221
"github.com/lightningnetwork/lnd/graph/db/models"
2322
"github.com/lightningnetwork/lnd/invoices"
2423
"github.com/lightningnetwork/lnd/lntypes"
@@ -75,8 +74,9 @@ type AddInvoiceConfig struct {
7574
// channel graph.
7675
ChanDB *channeldb.ChannelStateDB
7776

78-
// Graph holds a reference to the ChannelGraph database.
79-
Graph *graphdb.ChannelGraph
77+
// Graph gives the invoice server access to various graph related
78+
// queries.
79+
Graph GraphSource
8080

8181
// GenInvoiceFeatures returns a feature containing feature bits that
8282
// should be advertised on freshly generated invoices.

Diff for: lnrpc/invoicesrpc/config_active.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package invoicesrpc
66
import (
77
"github.com/btcsuite/btcd/chaincfg"
88
"github.com/lightningnetwork/lnd/channeldb"
9-
graphdb "github.com/lightningnetwork/lnd/graph/db"
109
"github.com/lightningnetwork/lnd/invoices"
1110
"github.com/lightningnetwork/lnd/lnwire"
1211
"github.com/lightningnetwork/lnd/macaroons"
@@ -52,9 +51,9 @@ type Config struct {
5251
// specified.
5352
DefaultCLTVExpiry uint32
5453

55-
// GraphDB is a global database instance which is needed to access the
56-
// channel graph.
57-
GraphDB *graphdb.ChannelGraph
54+
// Graph provides the invoices with information about the current LN
55+
// graph.
56+
Graph GraphSource
5857

5958
// ChanStateDB is a possibly replicated db instance which contains the
6059
// channel state

Diff for: lnrpc/invoicesrpc/interfaces.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package invoicesrpc
2+
3+
import (
4+
"github.com/lightningnetwork/lnd/graph/db/models"
5+
)
6+
7+
// GraphSource defines the graph interface required by the invoice rpc server.
8+
type GraphSource interface {
9+
// FetchChannelEdgesByID attempts to look up the two directed edges for
10+
// the channel identified by the channel ID. If the channel can't be
11+
// found, then graphdb.ErrEdgeNotFound is returned.
12+
FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo,
13+
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)
14+
15+
// IsPublicNode is a helper method that determines whether the node with
16+
// the given public key is seen as a public node in the graph from the
17+
// graph's source node's point of view.
18+
IsPublicNode(pubKey [33]byte) (bool, error)
19+
}

Diff for: lnrpc/invoicesrpc/invoices_server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func (s *Server) AddHoldInvoice(ctx context.Context,
346346
NodeSigner: s.cfg.NodeSigner,
347347
DefaultCLTVExpiry: s.cfg.DefaultCLTVExpiry,
348348
ChanDB: s.cfg.ChanStateDB,
349-
Graph: s.cfg.GraphDB,
349+
Graph: s.cfg.Graph,
350350
GenInvoiceFeatures: s.cfg.GenInvoiceFeatures,
351351
GenAmpInvoiceFeatures: s.cfg.GenAmpInvoiceFeatures,
352352
GetAlias: s.cfg.GetAlias,

Diff for: subrpcserver_config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
262262
subCfgValue.FieldByName("DefaultCLTVExpiry").Set(
263263
reflect.ValueOf(defaultDelta),
264264
)
265-
subCfgValue.FieldByName("GraphDB").Set(
265+
subCfgValue.FieldByName("Graph").Set(
266266
reflect.ValueOf(graphDB),
267267
)
268268
subCfgValue.FieldByName("ChanStateDB").Set(

0 commit comments

Comments
 (0)