graph+server: add template for new graph Builder sub-system

This is preparation for an upcoming commit that will move over various
responsibilities from the ChannelRouter to the graph Builder. So that
that commit can be a pure code-move commit, the template for the new
sub-system is added up front here.
This commit is contained in:
Elle Mouton committed 2024-07-15 15:56:33 +02:00
1 parent 30e6671a13
commit 0b7364f54b
4 files changed
+120

No files matched your search

+14
View File
@@ -41,6 +41,7 @@ import (
"github.com/lightningnetwork/lnd/feature"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/funding"
"github.com/lightningnetwork/lnd/graph"
"github.com/lightningnetwork/lnd/healthcheck"
"github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/htlcswitch/hop"
@@ -271,6 +272,8 @@ type server struct {
missionControl *routing.MissionControl
graphBuilder *graph.Builder
chanRouter *routing.ChannelRouter
controlTower routing.ControlTower
@@ -973,6 +976,11 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
strictPruning := cfg.Bitcoin.Node == "neutrino" ||
cfg.Routing.StrictZombiePruning
s.graphBuilder, err = graph.NewBuilder(&graph.Config{})
if err != nil {
return nil, fmt.Errorf("can't create graph builder: %w", err)
}
s.chanRouter, err = routing.New(routing.Config{
SelfNode: selfNode.PubKeyBytes,
RoutingGraph: graphsession.NewRoutingGraph(chanGraph),
@@ -2019,6 +2027,12 @@ func (s *server) Start() error {
}
cleanup = cleanup.add(s.authGossiper.Stop)
if err := s.graphBuilder.Start(); err != nil {
startErr = err
return
}
cleanup = cleanup.add(s.graphBuilder.Stop)
if err := s.chanRouter.Start(); err != nil {
startErr = err
return