mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 01:18:17 +02:00
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:
@@ -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