From c76d04ef918777cd4b9b73a03d097ea564ae4f47 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Thu, 28 Apr 2022 15:36:45 +0200 Subject: [PATCH] multi: make ZmqReadDeadline configurable Make the Bitcoind ZMQReadDeadline option configurable. --- chainreg/chainregistry.go | 2 +- config.go | 5 +++++ lncfg/bitcoind.go | 23 +++++++++++++---------- sample-lnd.conf | 2 ++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/chainreg/chainregistry.go b/chainreg/chainregistry.go index 86b3bd001..030757d45 100644 --- a/chainreg/chainregistry.go +++ b/chainreg/chainregistry.go @@ -409,7 +409,7 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) { ZMQConfig: &chain.ZMQConfig{ ZMQBlockHost: bitcoindMode.ZMQPubRawBlock, ZMQTxHost: bitcoindMode.ZMQPubRawTx, - ZMQReadDeadline: 5 * time.Second, + ZMQReadDeadline: bitcoindMode.ZMQReadDeadline, }, Dialer: cfg.Dialer, PrunedModeMaxPeers: bitcoindMode.PrunedNodeMaxPeers, diff --git a/config.go b/config.go index 42626581f..a18021233 100644 --- a/config.go +++ b/config.go @@ -83,6 +83,10 @@ const ( defaultTorV2PrivateKeyFilename = "v2_onion_private_key" defaultTorV3PrivateKeyFilename = "v3_onion_private_key" + // defaultZMQReadDeadline is the default read deadline to be used for + // both the block and tx ZMQ subscriptions. + defaultZMQReadDeadline = 5 * time.Second + // DefaultAutogenValidity is the default validity of a self-signed // certificate. The value corresponds to 14 months // (14 months * 30 days * 24 hours). @@ -483,6 +487,7 @@ func DefaultConfig() Config { RPCHost: defaultRPCHost, EstimateMode: defaultBitcoindEstimateMode, PrunedNodeMaxPeers: defaultPrunedNodeMaxPeers, + ZMQReadDeadline: defaultZMQReadDeadline, }, Litecoin: &lncfg.Chain{ MinHTLCIn: chainreg.DefaultLitecoinMinHTLCInMSat, diff --git a/lncfg/bitcoind.go b/lncfg/bitcoind.go index 904f9924b..55ec7d44b 100644 --- a/lncfg/bitcoind.go +++ b/lncfg/bitcoind.go @@ -1,16 +1,19 @@ package lncfg +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"` - 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."` } diff --git a/sample-lnd.conf b/sample-lnd.conf index 82ada3de7..3fa45dcb8 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -604,6 +604,7 @@ bitcoin.node=btcd ; likely won't need to be set (other than for a remote bitcoind instance). ; bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332 ; bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333 +; bitcoind.zmqreaddeadline=10s ; Fee estimate mode for bitcoind. It must be either "ECONOMICAL" or "CONSERVATIVE". ; If unset, the default value is "CONSERVATIVE". @@ -811,6 +812,7 @@ litecoin.node=ltcd ; likely won't need to be set (other than for a remote litecoind instance). ; litecoind.zmqpubrawblock=tcp://127.0.0.1:28332 ; litecoind.zmqpubrawtx=tcp://127.0.0.1:28333 +; litecoind.zmqreaddeadline=10s ; Fee estimate mode for litecoind. It must be either "ECONOMICAL" or "CONSERVATIVE". ; If unset, the default value is "CONSERVATIVE".