braidpool / bitcoin

Bitcoin Core integration/staging tree
https://bitcoincore.org/en/download
MIT License
1 stars 0 forks source link

ZMQ connection monitor #2

Closed mcelrath closed 2 months ago

mcelrath commented 2 months ago

Add ZMQ connection monitoring. Fixes #1

Bug #1 was caused by bitcoind not being started with the ZMQ port, so bitcoind is not listening and the mining script silently never connects to ZMQ but happily mines away and can't notice when a new block is mined by a different miner.

With this patch we use ZMQ's "monitor" functionality to tell whether the ZMQ connection is open, and abort with an error if we can't connect to ZMQ.

This does not retry the ZMQ connection, I assume the cpunet miner is running on the same host as bitcoind. In the future if we're connecting to ZMQ over a network and that connection fails, we might want to retry the connection instead of stopping the mining process.