chainntnfs: add block cache to BitcoindNotifier

This commit adds a blockcache pointer to BitcoindNotifier and wraps its
GetBlock method so that the block cache is used.
This commit is contained in:
Elle Mouton
2021-03-18 14:42:18 +02:00
parent f470946379
commit 8a33fbf11a
5 changed files with 48 additions and 13 deletions

View File

@@ -19,6 +19,7 @@ import (
"github.com/btcsuite/btcwallet/chain"
_ "github.com/btcsuite/btcwallet/walletdb/bdb" // Required to auto-register the boltdb walletdb implementation.
"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"
@@ -1930,6 +1931,8 @@ func TestInterfaces(t *testing.T, targetBackEnd string) {
t.Fatalf("unable to create height hint cache: %v", err)
}
blockCache := blockcache.NewBlockCache(10000)
var (
cleanUp func()
newNotifier func() (chainntnfs.TestChainNotifier, error)
@@ -1944,7 +1947,7 @@ func TestInterfaces(t *testing.T, targetBackEnd string) {
newNotifier = func() (chainntnfs.TestChainNotifier, error) {
return bitcoindnotify.New(
bitcoindConn, chainntnfs.NetParams,
hintCache, hintCache,
hintCache, hintCache, blockCache,
), nil
}