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

37
src/base/tools/bswap_64.h Normal file
View file

@ -0,0 +1,37 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_BSWAP_64_H
#define XMRIG_BSWAP_64_H
#ifdef _MSC_VER
#include <stdlib.h>
#define bswap_64(x) _byteswap_uint64(x)
#elif defined __GNUC__
#define bswap_64(x) __builtin_bswap64(x)
#else
#include <byteswap.h>
#endif
#endif /* XMRIG_BSWAP_64_H */

View file

@ -96,7 +96,7 @@ bool BlockTemplate::Init(const String& blockTemplate, Coin coin)
tx_extra_nonce_index = 0;
while (ar_extra.index() < extra_size) {
uint64_t extra_tag;
uint64_t extra_tag = 0;
ar_extra(extra_tag);
switch (extra_tag) {