From 7509af1a705f40b4999c9efe00de0f3c72a8d251 Mon Sep 17 00:00:00 2001 From: Orbital Date: Thu, 10 Mar 2022 10:01:44 +0000 Subject: [PATCH] multi: add rpcpolling config options --- chainreg/chainregistry.go | 34 ++++++++++++++++++++++------------ lncfg/bitcoind.go | 25 ++++++++++++++----------- sample-lnd.conf | 16 ++++++++++++++++ 3 files changed, 52 insertions(+), 23 deletions(-) diff --git a/chainreg/chainregistry.go b/chainreg/chainregistry.go index 030757d45..c2d44d6e8 100644 --- a/chainreg/chainregistry.go +++ b/chainreg/chainregistry.go @@ -399,21 +399,31 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) { } } - // Establish the connection to bitcoind and create the clients - // required for our relevant subsystems. - bitcoindConn, err := chain.NewBitcoindConn(&chain.BitcoindConfig{ - ChainParams: cfg.ActiveNetParams.Params, - Host: bitcoindHost, - User: bitcoindMode.RPCUser, - Pass: bitcoindMode.RPCPass, - ZMQConfig: &chain.ZMQConfig{ + bitcoindCfg := &chain.BitcoindConfig{ + ChainParams: cfg.ActiveNetParams.Params, + Host: bitcoindHost, + User: bitcoindMode.RPCUser, + Pass: bitcoindMode.RPCPass, + Dialer: cfg.Dialer, + PrunedModeMaxPeers: bitcoindMode.PrunedNodeMaxPeers, + } + + if bitcoindMode.RPCPolling { + bitcoindCfg.PollingConfig = &chain.PollingConfig{ + BlockPollingInterval: bitcoindMode.BlockPollingInterval, + TxPollingInterval: bitcoindMode.TxPollingInterval, + } + } else { + bitcoindCfg.ZMQConfig = &chain.ZMQConfig{ ZMQBlockHost: bitcoindMode.ZMQPubRawBlock, ZMQTxHost: bitcoindMode.ZMQPubRawTx, ZMQReadDeadline: bitcoindMode.ZMQReadDeadline, - }, - Dialer: cfg.Dialer, - PrunedModeMaxPeers: bitcoindMode.PrunedNodeMaxPeers, - }) + } + } + + // Establish the connection to bitcoind and create the clients + // required for our relevant subsystems. + bitcoindConn, err := chain.NewBitcoindConn(bitcoindCfg) if err != nil { return nil, nil, err } diff --git a/lncfg/bitcoind.go b/lncfg/bitcoind.go index 55ec7d44b..cf0f00232 100644 --- a/lncfg/bitcoind.go +++ b/lncfg/bitcoind.go @@ -5,15 +5,18 @@ import "time" // Bitcoind holds the configuration options for the daemon's connection to // bitcoind. type Bitcoind struct { - Dir string `long:"dir" description:"The base directory that contains the node's data, logs, configuration file, etc."` - ConfigPath string `long:"config" description:"Configuration filepath. If not set, will default to the default filename under 'dir'."` - RPCCookie string `long:"rpccookie" description:"Authentication cookie file for RPC connections. If not set, will default to .cookie under 'dir'."` - RPCHost string `long:"rpchost" description:"The daemon's rpc listening address. If a port is omitted, then the default port for the selected chain parameters will be used."` - RPCUser string `long:"rpcuser" description:"Username for RPC connections"` - RPCPass string `long:"rpcpass" default-mask:"-" description:"Password for RPC connections"` - ZMQPubRawBlock string `long:"zmqpubrawblock" description:"The address listening for ZMQ connections to deliver raw block notifications"` - ZMQPubRawTx string `long:"zmqpubrawtx" description:"The address listening for ZMQ connections to deliver raw transaction notifications"` - ZMQReadDeadline time.Duration `long:"zmqreaddeadline" description:"The read deadline for reading ZMQ messages from both the block and tx subscriptions"` - EstimateMode string `long:"estimatemode" description:"The fee estimate mode. Must be either ECONOMICAL or CONSERVATIVE."` - PrunedNodeMaxPeers int `long:"pruned-node-max-peers" description:"The maximum number of peers lnd will choose from the backend node to retrieve pruned blocks from. This only applies to pruned nodes."` + Dir string `long:"dir" description:"The base directory that contains the node's data, logs, configuration file, etc."` + ConfigPath string `long:"config" description:"Configuration filepath. If not set, will default to the default filename under 'dir'."` + RPCCookie string `long:"rpccookie" description:"Authentication cookie file for RPC connections. If not set, will default to .cookie under 'dir'."` + RPCHost string `long:"rpchost" description:"The daemon's rpc listening address. If a port is omitted, then the default port for the selected chain parameters will be used."` + RPCUser string `long:"rpcuser" description:"Username for RPC connections"` + RPCPass string `long:"rpcpass" default-mask:"-" description:"Password for RPC connections"` + ZMQPubRawBlock string `long:"zmqpubrawblock" description:"The address listening for ZMQ connections to deliver raw block notifications"` + ZMQPubRawTx string `long:"zmqpubrawtx" description:"The address listening for ZMQ connections to deliver raw transaction notifications"` + ZMQReadDeadline time.Duration `long:"zmqreaddeadline" description:"The read deadline for reading ZMQ messages from both the block and tx subscriptions"` + EstimateMode string `long:"estimatemode" description:"The fee estimate mode. Must be either ECONOMICAL or CONSERVATIVE."` + PrunedNodeMaxPeers int `long:"pruned-node-max-peers" description:"The maximum number of peers lnd will choose from the backend node to retrieve pruned blocks from. This only applies to pruned nodes."` + RPCPolling bool `long:"rpcpolling" description:"Poll the bitcoind RPC interface for block and transaction notifications instead of using the ZMQ interface"` + BlockPollingInterval time.Duration `long:"blockpollinginterval" description:"The interval that will be used to poll bitcoind for new blocks. Only used if rpcpolling is true."` + TxPollingInterval time.Duration `long:"txpollinginterval" description:"The interval that will be used to poll bitcoind for new tx. Only used if rpcpolling is true."` } diff --git a/sample-lnd.conf b/sample-lnd.conf index 3fa45dcb8..114ad5c19 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -606,6 +606,14 @@ bitcoin.node=btcd ; bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333 ; bitcoind.zmqreaddeadline=10s +; Use bitcoind's rpc interface to get block and transaction notifications +; instead of using the zmq interface. Only the rpcpolling option needs to +; be set in order to enable this, the rest of the options can be used to +; change the default values used for this configuration. +; bitcoind.rpcpolling +; bitcoind.blockpollinginterval=1m +; bitcoind.txpollinginterval=30s + ; Fee estimate mode for bitcoind. It must be either "ECONOMICAL" or "CONSERVATIVE". ; If unset, the default value is "CONSERVATIVE". ; bitcoind.estimatemode=CONSERVATIVE @@ -814,6 +822,14 @@ litecoin.node=ltcd ; litecoind.zmqpubrawtx=tcp://127.0.0.1:28333 ; litecoind.zmqreaddeadline=10s +; Use litecoind's rpc interface to get block and transaction notifications +; instead of using the zmq interface. Only the rpcpolling option needs to +; be set in order to enable this, the rest of the options can be used to +; change the default values used for this configuration. +; litecoind.rpcpolling +; litecoind.blockpollinginterval=1m +; litecoind.txpollinginterval=30s + ; Fee estimate mode for litecoind. It must be either "ECONOMICAL" or "CONSERVATIVE". ; If unset, the default value is "CONSERVATIVE". ; litecoind.estimatemode=CONSERVATIVE