From 15e5052dd0e08c1a8a6de9aff6d8599f38ce35e9 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 28 Nov 2021 12:07:11 +0100 Subject: [PATCH] More GhostRider fixes - Fixed "difficulty is not a number" when diff is high on some pools - Fixed GhostRider compilation when WITH_KAWPOW=OFF --- src/base/base.cmake | 2 +- src/base/net/stratum/EthStratumClient.cpp | 5 +++-- src/base/net/stratum/Pool.cpp | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/base/base.cmake b/src/base/base.cmake index 3246d6f99..5761a09b5 100644 --- a/src/base/base.cmake +++ b/src/base/base.cmake @@ -244,7 +244,7 @@ else() endif() -if (WITH_KAWPOW) +if (WITH_KAWPOW OR WITH_GHOSTRIDER) list(APPEND HEADERS_BASE src/base/net/stratum/AutoClient.h src/base/net/stratum/EthStratumClient.h diff --git a/src/base/net/stratum/EthStratumClient.cpp b/src/base/net/stratum/EthStratumClient.cpp index 830d52775..3ebce7086 100644 --- a/src/base/net/stratum/EthStratumClient.cpp +++ b/src/base/net/stratum/EthStratumClient.cpp @@ -213,12 +213,13 @@ void xmrig::EthStratumClient::parseNotification(const char *method, const rapidj return; } - if (!arr[0].IsDouble()) { + if (!arr[0].IsDouble() && !arr[0].IsUint64()) { LOG_ERR("%s " RED("invalid mining.set_difficulty notification: difficulty is not a number"), tag()); return; } - m_nextDifficulty = static_cast(ceil(arr[0].GetDouble() * 65536.0)); + const double diff = arr[0].IsDouble() ? arr[0].GetDouble() : arr[0].GetUint64(); + m_nextDifficulty = static_cast(ceil(diff * 65536.0)); } # endif diff --git a/src/base/net/stratum/Pool.cpp b/src/base/net/stratum/Pool.cpp index ef644a54b..7a58f4cb5 100644 --- a/src/base/net/stratum/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -31,7 +31,7 @@ #include "base/kernel/Platform.h" #include "base/net/stratum/Client.h" -#ifdef XMRIG_ALGO_KAWPOW +#if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER # include "base/net/stratum/AutoClient.h" # include "base/net/stratum/EthStratumClient.h" #endif @@ -218,7 +218,7 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con IClient *client = nullptr; if (m_mode == MODE_POOL) { -# ifdef XMRIG_ALGO_KAWPOW +# if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER const uint32_t f = m_algorithm.family(); if ((f == Algorithm::KAWPOW) || (f == Algorithm::GHOSTRIDER) || (m_coin == Coin::RAVEN)) { client = new EthStratumClient(id, Platform::userAgent(), listener); @@ -237,7 +237,7 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con client = new SelfSelectClient(id, Platform::userAgent(), listener, m_submitToOrigin); } # endif -# ifdef XMRIG_ALGO_KAWPOW +# if defined XMRIG_ALGO_KAWPOW || defined XMRIG_ALGO_GHOSTRIDER else if (m_mode == MODE_AUTO_ETH) { client = new AutoClient(id, Platform::userAgent(), listener); }