chainntnfs: add block cache to BtcdNotifier
This commit adds gives BtcdNotifier access to the block cache and wraps its GetBlock method so that it uses the block cache.
This commit is contained in:
1 parent
8a33fbf11a
commit
a0f7bf8b2d
6 files changed
+40
-10
No files matched your search
@@ -6,15 +6,16 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/rpcclient"
|
||||
"github.com/lightningnetwork/lnd/blockcache"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
)
|
||||
|
||||
// createNewNotifier creates a new instance of the ChainNotifier interface
|
||||
// implemented by BtcdNotifier.
|
||||
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))
|
||||
}
|
||||
|
||||
config, ok := args[0].(*rpcclient.ConnConfig)
|
||||
@@ -41,7 +42,15 @@ func createNewNotifier(args ...interface{}) (chainntnfs.ChainNotifier, error) {
|
||||
"is incorrect, expected a chainntnfs.ConfirmHintCache")
|
||||
}
|
||||
|
||||
return New(config, chainParams, spendHintCache, confirmHintCache)
|
||||
blockCache, ok := args[4].(*blockcache.BlockCache)
|
||||
if !ok {
|
||||
return nil, errors.New("fifth argument to btcdnotify.New " +
|
||||
"is incorrect, expected a *blockcache.BlockCache")
|
||||
}
|
||||
|
||||
return New(
|
||||
config, chainParams, spendHintCache, confirmHintCache, blockCache,
|
||||
)
|
||||
}
|
||||
|
||||
// init registers a driver for the BtcdNotifier concrete implementation of the
|
||||
|
||||
Reference in new issue
Block a user