lnd+graph: add GraphBootstrapper to the GraphSource interface

So that LND can use a different GraphSource for network bootstrapping
and does not need to rely on its local graph db.
This commit is contained in:
Elle Mouton
2024-11-12 08:49:34 +02:00
parent 0f33d41c55
commit 372883ab81
3 changed files with 22 additions and 2 deletions

View File

@@ -8,6 +8,8 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/discovery"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/graph/session"
@@ -217,6 +219,18 @@ func (s *DBSource) FetchLightningNode(_ context.Context,
return s.db.FetchLightningNode(nodePub)
}
// GraphBootstrapper returns a NetworkPeerBootstrapper instance backed by the
// ChannelGraph instance.
//
// NOTE: this is part of the GraphSource interface.
func (s *DBSource) GraphBootstrapper(_ context.Context) (
discovery.NetworkPeerBootstrapper, error) {
chanGraph := autopilot.ChannelGraphFromDatabase(s.db)
return discovery.NewGraphBootstrapper(chanGraph)
}
// kvdbRTx is an implementation of graphdb.RTx backed by a KVDB database read
// transaction.
type kvdbRTx struct {