mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 01:18:17 +02:00
chainntnfs: add height hint caches to chain notifiers
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package bitcoindnotify
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcwallet/chain"
|
||||
@@ -10,18 +11,30 @@ import (
|
||||
// createNewNotifier creates a new instance of the ChainNotifier interface
|
||||
// implemented by BitcoindNotifier.
|
||||
func createNewNotifier(args ...interface{}) (chainntnfs.ChainNotifier, error) {
|
||||
if len(args) != 1 {
|
||||
if len(args) != 3 {
|
||||
return nil, fmt.Errorf("incorrect number of arguments to "+
|
||||
".New(...), expected 1, instead passed %v", len(args))
|
||||
".New(...), expected 2, instead passed %v", len(args))
|
||||
}
|
||||
|
||||
chainConn, ok := args[0].(*chain.BitcoindConn)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("first argument to bitcoindnotify.New " +
|
||||
return nil, errors.New("first argument to bitcoindnotify.New " +
|
||||
"is incorrect, expected a *chain.BitcoindConn")
|
||||
}
|
||||
|
||||
return New(chainConn), nil
|
||||
spendHintCache, ok := args[1].(chainntnfs.SpendHintCache)
|
||||
if !ok {
|
||||
return nil, errors.New("second argument to bitcoindnotify.New " +
|
||||
"is incorrect, expected a chainntnfs.SpendHintCache")
|
||||
}
|
||||
|
||||
confirmHintCache, ok := args[2].(chainntnfs.ConfirmHintCache)
|
||||
if !ok {
|
||||
return nil, errors.New("third argument to bitcoindnotify.New " +
|
||||
"is incorrect, expected a chainntnfs.ConfirmHintCache")
|
||||
}
|
||||
|
||||
return New(chainConn, spendHintCache, confirmHintCache), nil
|
||||
}
|
||||
|
||||
// init registers a driver for the BtcdNotifier concrete implementation of the
|
||||
|
Reference in New Issue
Block a user