ZeroMQ support for solo mining

Gets new blocks from daemon immediately without polling, saving ~0.5 seconds on average when daemon gets new block from the network. Also saves some CPU cycles because it doesn't need to poll daemon every second.

Testing: add "daemon-zmq-port": 28083 to xmrig's pool config in config.json and run ./monerod --testnet --zmq-pub tcp://127.0.0.1:28083
This commit is contained in:
SChernykh 2021-07-15 11:13:14 +02:00
parent 93805cd167
commit 0842e6b9d2
12 changed files with 482 additions and 35 deletions

View file

@ -72,6 +72,7 @@ public:
static const char *kUrl;
static const char *kUser;
static const char* kSpendSecretKey;
static const char* kDaemonZMQPort;
static const char *kNicehashHost;
constexpr static int kKeepAliveTimeout = 60;
@ -107,6 +108,7 @@ public:
inline int keepAlive() const { return m_keepAlive; }
inline Mode mode() const { return m_mode; }
inline uint16_t port() const { return m_url.port(); }
inline int zmq_port() const { return m_zmqPort; }
inline uint64_t pollInterval() const { return m_pollInterval; }
inline void setAlgo(const Algorithm &algorithm) { m_algorithm = algorithm; }
inline void setPassword(const String &password) { m_password = password; }
@ -155,6 +157,7 @@ private:
uint64_t m_pollInterval = kDefaultPollInterval;
Url m_daemon;
Url m_url;
int m_zmqPort = -1;
# ifdef XMRIG_FEATURE_BENCHMARK
std::shared_ptr<BenchConfig> m_benchmark;