chainreg+lnd: add block cache to chainreg config
The block cache size in the chainreg.Config previously wasn't used but instead the block cache was passed in as a separate parameter. We replace the cache size with the actual cache in the config to streamline things somewhat.
This commit is contained in:
2 files changed
+13
-15
No files matched your search
+10
-12
@@ -77,8 +77,8 @@ type Config struct {
|
|||||||
// state.
|
// state.
|
||||||
ChanStateDB *channeldb.ChannelStateDB
|
ChanStateDB *channeldb.ChannelStateDB
|
||||||
|
|
||||||
// BlockCacheSize is the size (in bytes) of blocks kept in memory.
|
// BlockCache is the main cache for storing block information.
|
||||||
BlockCacheSize uint64
|
BlockCache *blockcache.BlockCache
|
||||||
|
|
||||||
// PrivateWalletPw is the private wallet password to the underlying
|
// PrivateWalletPw is the private wallet password to the underlying
|
||||||
// btcwallet instance.
|
// btcwallet instance.
|
||||||
@@ -245,9 +245,7 @@ func GenDefaultBtcConstraints() channeldb.ChannelConstraints {
|
|||||||
// full-node, another backed by a running bitcoind full-node, and the other
|
// full-node, another backed by a running bitcoind full-node, and the other
|
||||||
// backed by a running neutrino light client instance. When running with a
|
// backed by a running neutrino light client instance. When running with a
|
||||||
// neutrino light client instance, `neutrinoCS` must be non-nil.
|
// neutrino light client instance, `neutrinoCS` must be non-nil.
|
||||||
func NewChainControl(cfg *Config, blockCache *blockcache.BlockCache) (
|
func NewChainControl(cfg *Config) (*ChainControl, func(), error) {
|
||||||
*ChainControl, func(), error) {
|
|
||||||
|
|
||||||
// Set the RPC config from the "home" chain. Multi-chain isn't yet
|
// Set the RPC config from the "home" chain. Multi-chain isn't yet
|
||||||
// active, so we'll restrict usage to a particular chain for now.
|
// active, so we'll restrict usage to a particular chain for now.
|
||||||
homeChainConfig := cfg.Bitcoin
|
homeChainConfig := cfg.Bitcoin
|
||||||
@@ -327,10 +325,10 @@ func NewChainControl(cfg *Config, blockCache *blockcache.BlockCache) (
|
|||||||
// along with the wallet's ChainSource, which are all backed by
|
// along with the wallet's ChainSource, which are all backed by
|
||||||
// the neutrino light client.
|
// the neutrino light client.
|
||||||
cc.ChainNotifier = neutrinonotify.New(
|
cc.ChainNotifier = neutrinonotify.New(
|
||||||
cfg.NeutrinoCS, hintCache, hintCache, blockCache,
|
cfg.NeutrinoCS, hintCache, hintCache, cfg.BlockCache,
|
||||||
)
|
)
|
||||||
cc.ChainView, err = chainview.NewCfFilteredChainView(
|
cc.ChainView, err = chainview.NewCfFilteredChainView(
|
||||||
cfg.NeutrinoCS, blockCache,
|
cfg.NeutrinoCS, cfg.BlockCache,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@@ -432,10 +430,10 @@ func NewChainControl(cfg *Config, blockCache *blockcache.BlockCache) (
|
|||||||
|
|
||||||
cc.ChainNotifier = bitcoindnotify.New(
|
cc.ChainNotifier = bitcoindnotify.New(
|
||||||
bitcoindConn, cfg.ActiveNetParams.Params, hintCache,
|
bitcoindConn, cfg.ActiveNetParams.Params, hintCache,
|
||||||
hintCache, blockCache,
|
hintCache, cfg.BlockCache,
|
||||||
)
|
)
|
||||||
cc.ChainView = chainview.NewBitcoindFilteredChainView(
|
cc.ChainView = chainview.NewBitcoindFilteredChainView(
|
||||||
bitcoindConn, blockCache,
|
bitcoindConn, cfg.BlockCache,
|
||||||
)
|
)
|
||||||
walletConfig.ChainSource = bitcoindConn.NewBitcoindClient()
|
walletConfig.ChainSource = bitcoindConn.NewBitcoindClient()
|
||||||
|
|
||||||
@@ -564,7 +562,7 @@ func NewChainControl(cfg *Config, blockCache *blockcache.BlockCache) (
|
|||||||
}
|
}
|
||||||
cc.ChainNotifier, err = btcdnotify.New(
|
cc.ChainNotifier, err = btcdnotify.New(
|
||||||
rpcConfig, cfg.ActiveNetParams.Params, hintCache,
|
rpcConfig, cfg.ActiveNetParams.Params, hintCache,
|
||||||
hintCache, blockCache,
|
hintCache, cfg.BlockCache,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@@ -573,7 +571,7 @@ func NewChainControl(cfg *Config, blockCache *blockcache.BlockCache) (
|
|||||||
// Finally, we'll create an instance of the default chain view to be
|
// Finally, we'll create an instance of the default chain view to be
|
||||||
// used within the routing layer.
|
// used within the routing layer.
|
||||||
cc.ChainView, err = chainview.NewBtcdFilteredChainView(
|
cc.ChainView, err = chainview.NewBtcdFilteredChainView(
|
||||||
*rpcConfig, blockCache,
|
*rpcConfig, cfg.BlockCache,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("unable to create chain view: %v", err)
|
log.Errorf("unable to create chain view: %v", err)
|
||||||
@@ -666,7 +664,7 @@ func NewChainControl(cfg *Config, blockCache *blockcache.BlockCache) (
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
wc, err := btcwallet.New(*walletConfig, blockCache)
|
wc, err := btcwallet.New(*walletConfig, cfg.BlockCache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("unable to create wallet controller: %v\n", err)
|
fmt.Printf("unable to create wallet controller: %v\n", err)
|
||||||
return nil, ccCleanup, err
|
return nil, ccCleanup, err
|
||||||
|
|||||||
@@ -729,8 +729,8 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
|||||||
Dialer: func(addr string) (net.Conn, error) {
|
Dialer: func(addr string) (net.Conn, error) {
|
||||||
return cfg.net.Dial("tcp", addr, cfg.ConnectionTimeout)
|
return cfg.net.Dial("tcp", addr, cfg.ConnectionTimeout)
|
||||||
},
|
},
|
||||||
BlockCacheSize: cfg.BlockCacheSize,
|
BlockCache: blockCache,
|
||||||
LoaderOptions: []btcwallet.LoaderOption{dbs.walletDB},
|
LoaderOptions: []btcwallet.LoaderOption{dbs.walletDB},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse coin selection strategy.
|
// Parse coin selection strategy.
|
||||||
@@ -747,7 +747,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
activeChainControl, cleanup, err := chainreg.NewChainControl(
|
activeChainControl, cleanup, err := chainreg.NewChainControl(
|
||||||
chainControlCfg, blockCache,
|
chainControlCfg,
|
||||||
)
|
)
|
||||||
if cleanup != nil {
|
if cleanup != nil {
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|||||||
Reference in new issue
Block a user