btcwallet: make blockcache available to BtcWallet

This commit makes the blockcache available to BtcWallet so that any
GetBlock call made to BtcWallet is wrapped by the blockcache GetBlock
call.
This commit is contained in:
Elle Mouton
2021-03-18 14:08:53 +02:00
parent 6702c79216
commit 106f93a1b4
5 changed files with 30 additions and 8 deletions

View File

@@ -19,6 +19,7 @@ import (
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/wallet"
"github.com/lightninglabs/neutrino"
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/chainntnfs/bitcoindnotify"
"github.com/lightningnetwork/lnd/chainntnfs/btcdnotify"
@@ -306,6 +307,9 @@ func NewChainControl(cfg *Config) (*ChainControl, func(), error) {
"cache: %v", err)
}
// Initialize a new block cache.
blockCache := blockcache.NewBlockCache(cfg.BlockCacheSize)
// If spv mode is active, then we'll be using a distinct set of
// chainControl interfaces that interface directly with the p2p network
// of the selected chain.
@@ -641,7 +645,7 @@ func NewChainControl(cfg *Config) (*ChainControl, func(), error) {
return nil, nil, err
}
wc, err := btcwallet.New(*walletConfig)
wc, err := btcwallet.New(*walletConfig, blockCache)
if err != nil {
fmt.Printf("unable to create wallet controller: %v\n", err)
return nil, ccCleanup, err