From c039aee0590866d0d6b4cb0fa7d7c6ff4ee551ed Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Tue, 28 Apr 2020 11:15:44 -0700 Subject: [PATCH] chainregistry: increase zmq connection timeout with bitcoind backend There seems to be a misinterpretation of a variable between the btcwallet and gozmq libraries. When establish a ZMQ connection, it expects a timeout, which is used to set read deadlines and determine how long we should wait before attempting a reconnection. Within btcwallet and lnd however, this is is interpreted as a polling duration, explaining the current value of 100ms. Under load, especially on less-capable hardware, this leads to high resource usage as we get into a constant reconnection loop. To remedy this, we use a timeout of 5s instead, which is a much more reasonable value for read timeouts, and is also what's used for LN peers. --- chainregistry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chainregistry.go b/chainregistry.go index b5df1cf1..cd5a3787 100644 --- a/chainregistry.go +++ b/chainregistry.go @@ -314,7 +314,7 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB, activeNetParams.Params, bitcoindHost, bitcoindMode.RPCUser, bitcoindMode.RPCPass, bitcoindMode.ZMQPubRawBlock, bitcoindMode.ZMQPubRawTx, - 100*time.Millisecond, + 5*time.Second, ) if err != nil { return nil, err