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:
1 parent
f470946379
commit
8a33fbf11a
5 files changed
+48
-13
No files matched your search
@@ -6,15 +6,16 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcwallet/chain"
|
||||
"github.com/lightningnetwork/lnd/blockcache"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
)
|
||||
|
||||
// createNewNotifier creates a new instance of the ChainNotifier interface
|
||||
// implemented by BitcoindNotifier.
|
||||
func createNewNotifier(args ...interface{}) (chainntnfs.ChainNotifier, error) {
|
||||
if len(args) != 4 {
|
||||
if len(args) != 5 {
|
||||
return nil, fmt.Errorf("incorrect number of arguments to "+
|
||||
".New(...), expected 4, instead passed %v", len(args))
|
||||
".New(...), expected 5, instead passed %v", len(args))
|
||||
}
|
||||
|
||||
chainConn, ok := args[0].(*chain.BitcoindConn)
|
||||
@@ -41,7 +42,14 @@ func createNewNotifier(args ...interface{}) (chainntnfs.ChainNotifier, error) {
|
||||
"is incorrect, expected a chainntnfs.ConfirmHintCache")
|
||||
}
|
||||
|
||||
return New(chainConn, chainParams, spendHintCache, confirmHintCache), nil
|
||||
blockCache, ok := args[4].(*blockcache.BlockCache)
|
||||
if !ok {
|
||||
return nil, errors.New("fifth argument to bitcoindnotify.New " +
|
||||
"is incorrect, expected a *blockcache.BlockCache")
|
||||
}
|
||||
|
||||
return New(chainConn, chainParams, spendHintCache,
|
||||
confirmHintCache, blockCache), nil
|
||||
}
|
||||
|
||||
// init registers a driver for the BtcdNotifier concrete implementation of the
|
||||
|
||||
Reference in new issue
Block a user