chainntnfs: add height hint caches to chain notifiers
This commit is contained in:
10 files changed
+138
-30
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package btcdnotify
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/rpcclient"
|
||||
@@ -10,18 +11,30 @@ import (
|
||||
// createNewNotifier creates a new instance of the ChainNotifier interface
|
||||
// implemented by BtcdNotifier.
|
||||
func createNewNotifier(args ...interface{}) (chainntnfs.ChainNotifier, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf("incorrect number of arguments to .New(...), "+
|
||||
"expected 1, instead passed %v", len(args))
|
||||
if len(args) != 3 {
|
||||
return nil, fmt.Errorf("incorrect number of arguments to "+
|
||||
".New(...), expected 2, instead passed %v", len(args))
|
||||
}
|
||||
|
||||
config, ok := args[0].(*rpcclient.ConnConfig)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("first argument to btcdnotifier.New is " +
|
||||
"incorrect, expected a *rpcclient.ConnConfig")
|
||||
return nil, errors.New("first argument to btcdnotifier.New " +
|
||||
"is incorrect, expected a *rpcclient.ConnConfig")
|
||||
}
|
||||
|
||||
return New(config)
|
||||
spendHintCache, ok := args[1].(chainntnfs.SpendHintCache)
|
||||
if !ok {
|
||||
return nil, errors.New("second argument to btcdnotifier.New " +
|
||||
"is incorrect, expected a chainntnfs.SpendHintCache")
|
||||
}
|
||||
|
||||
confirmHintCache, ok := args[2].(chainntnfs.ConfirmHintCache)
|
||||
if !ok {
|
||||
return nil, errors.New("third argument to btcdnotifier.New " +
|
||||
"is incorrect, expected a chainntnfs.ConfirmHintCache")
|
||||
}
|
||||
|
||||
return New(config, spendHintCache, confirmHintCache)
|
||||
}
|
||||
|
||||
// init registers a driver for the BtcdNotifier concrete implementation of the
|
||||
|
||||
Reference in new issue
Block a user