mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 22:50:58 +02:00
multi: init neutrino backend with block cache
This commit initializes the nwutrino backend with the lnd blockcache so that the two can share a block cache instead of each having its own.
This commit is contained in:
14
lnd.go
14
lnd.go
@@ -34,6 +34,7 @@ import (
|
||||
"gopkg.in/macaroon.v2"
|
||||
|
||||
"github.com/lightningnetwork/lnd/autopilot"
|
||||
"github.com/lightningnetwork/lnd/blockcache"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"github.com/lightningnetwork/lnd/cert"
|
||||
"github.com/lightningnetwork/lnd/chainreg"
|
||||
@@ -254,6 +255,9 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
||||
|
||||
defer cleanUp()
|
||||
|
||||
// Initialize a new block cache.
|
||||
blockCache := blockcache.NewBlockCache(cfg.BlockCacheSize)
|
||||
|
||||
// Before starting the wallet, we'll create and start our Neutrino
|
||||
// light client instance, if enabled, in order to allow it to sync
|
||||
// while the rest of the daemon continues startup.
|
||||
@@ -264,7 +268,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
||||
var neutrinoCS *neutrino.ChainService
|
||||
if mainChain.Node == "neutrino" {
|
||||
neutrinoBackend, neutrinoCleanUp, err := initNeutrinoBackend(
|
||||
cfg, mainChain.ChainDir,
|
||||
cfg, mainChain.ChainDir, blockCache,
|
||||
)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to initialize neutrino "+
|
||||
@@ -549,7 +553,9 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
||||
BlockCacheSize: cfg.BlockCacheSize,
|
||||
}
|
||||
|
||||
activeChainControl, cleanup, err := chainreg.NewChainControl(chainControlCfg)
|
||||
activeChainControl, cleanup, err := chainreg.NewChainControl(
|
||||
chainControlCfg, blockCache,
|
||||
)
|
||||
if cleanup != nil {
|
||||
defer cleanup()
|
||||
}
|
||||
@@ -1554,7 +1560,8 @@ func initializeDatabases(ctx context.Context,
|
||||
|
||||
// initNeutrinoBackend inits a new instance of the neutrino light client
|
||||
// backend given a target chain directory to store the chain state.
|
||||
func initNeutrinoBackend(cfg *Config, chainDir string) (*neutrino.ChainService,
|
||||
func initNeutrinoBackend(cfg *Config, chainDir string,
|
||||
blockCache *blockcache.BlockCache) (*neutrino.ChainService,
|
||||
func(), error) {
|
||||
|
||||
// Both channel validation flags are false by default but their meaning
|
||||
@@ -1662,6 +1669,7 @@ func initNeutrinoBackend(cfg *Config, chainDir string) (*neutrino.ChainService,
|
||||
return ips, nil
|
||||
},
|
||||
AssertFilterHeader: headerStateAssertion,
|
||||
BlockCache: blockCache.Cache,
|
||||
}
|
||||
|
||||
neutrino.MaxPeers = 8
|
||||
|
Reference in New Issue
Block a user