mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-18 10:06:51 +01:00
lnd+graph: add GraphSource interface and implementation
This commit adds a new GraphSources interface that LND requires for graph related read-only queries. As of this commit, the interface is empty but it will be populated over the next couple of commits. We add an implementation of this interface backed by a pointer to a graphdb.ChannelGraph. The infrustructure is put into place so that the GraphSoure provided to LND can be overridden by a caller of the lnd.Main function. By default, LND will satisfy the interface itself via the new `graphsource.DBSource` struct.
This commit is contained in:
@@ -45,6 +45,7 @@ import (
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
graphsession "github.com/lightningnetwork/lnd/graph/session"
|
||||
"github.com/lightningnetwork/lnd/graph/sources"
|
||||
"github.com/lightningnetwork/lnd/healthcheck"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch/hop"
|
||||
@@ -261,6 +262,10 @@ type server struct {
|
||||
|
||||
graphDB *graphdb.ChannelGraph
|
||||
|
||||
// graphSource can be used for any read only graph queries. This may be
|
||||
// implemented by this LND node or some other external source.
|
||||
graphSource sources.GraphSource
|
||||
|
||||
chanStateDB *channeldb.ChannelStateDB
|
||||
|
||||
addrSource channeldb.AddrSource
|
||||
@@ -507,7 +512,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
chansToRestore walletunlocker.ChannelsToRecover,
|
||||
chanPredicate chanacceptor.ChannelAcceptor,
|
||||
torController *tor.Controller, tlsManager *TLSManager,
|
||||
leaderElector cluster.LeaderElector,
|
||||
leaderElector cluster.LeaderElector, graphSource sources.GraphSource,
|
||||
implCfg *ImplementationCfg) (*server, error) {
|
||||
|
||||
var (
|
||||
@@ -613,6 +618,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
cfg: cfg,
|
||||
implCfg: implCfg,
|
||||
graphDB: dbs.GraphDB,
|
||||
graphSource: graphSource,
|
||||
chanStateDB: dbs.ChanStateDB.ChannelStateDB(),
|
||||
addrSource: addrSource,
|
||||
miscDB: dbs.ChanStateDB,
|
||||
|
||||
Reference in New Issue
Block a user