multi: update to latest BitcoindClient interface
In this commit, we introduce a nice optimization with regards to lnd's interaction with a bitcoind backend. Within lnd, we currently have three different subsystems responsible for watching the chain: chainntnfs, lnwallet, and routing/chainview. Each of these subsystems has an active RPC and ZMQ connection to the underlying bitcoind node. This would incur a toll on the underlying bitcoind node and would cause us to miss ZMQ events, which are crucial to lnd. We remedy this issue by sharing the same connection to a bitcoind node between the different clients within lnd.
This commit is contained in:
7 files changed
+138
-162
No files matched your search
@@ -3,38 +3,25 @@ package bitcoindnotify
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/rpcclient"
|
||||
"github.com/btcsuite/btcwallet/chain"
|
||||
"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) != 3 {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf("incorrect number of arguments to "+
|
||||
".New(...), expected 3, instead passed %v", len(args))
|
||||
".New(...), expected 1, instead passed %v", len(args))
|
||||
}
|
||||
|
||||
config, ok := args[0].(*rpcclient.ConnConfig)
|
||||
chainConn, ok := args[0].(*chain.BitcoindConn)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("first argument to bitcoindnotifier." +
|
||||
"New is incorrect, expected a *rpcclient.ConnConfig")
|
||||
return nil, fmt.Errorf("first argument to bitcoindnotify.New " +
|
||||
"is incorrect, expected a *chain.BitcoindConn")
|
||||
}
|
||||
|
||||
zmqConnect, ok := args[1].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("second argument to bitcoindnotifier." +
|
||||
"New is incorrect, expected a string")
|
||||
}
|
||||
|
||||
params, ok := args[2].(chaincfg.Params)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("third argument to bitcoindnotifier." +
|
||||
"New is incorrect, expected a chaincfg.Params")
|
||||
}
|
||||
|
||||
return New(config, zmqConnect, params)
|
||||
return New(chainConn), nil
|
||||
}
|
||||
|
||||
// init registers a driver for the BtcdNotifier concrete implementation of the
|
||||
|
||||
Reference in new issue
Block a user