From c080d5b962fe4bb77342f92293bff68aa332c996 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Tue, 6 Apr 2021 23:02:10 +0200 Subject: [PATCH] Fixed broken "coin" setting functionality --- src/base/net/stratum/Client.cpp | 9 +++++++-- src/base/net/stratum/DaemonClient.cpp | 4 +++- src/base/net/stratum/SelfSelectClient.cpp | 13 +++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index 78c0976f7..e4d1d53ae 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -379,11 +379,16 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code) } const char *algo = Json::getString(params, "algo"); + const char *blobData = Json::getString(params, "blob"); if (algo) { job.setAlgorithm(algo); } else if (m_pool.coin().isValid()) { - job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0])); + uint8_t blobVersion = 0; + if (blobData) { + Cvt::fromHex(&blobVersion, 1, blobData, 2); + } + job.setAlgorithm(m_pool.coin().algorithm(blobVersion)); } # ifdef XMRIG_FEATURE_HTTP @@ -399,7 +404,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code) else # endif { - if (!job.setBlob(params["blob"].GetString())) { + if (!job.setBlob(blobData)) { *code = 4; return false; } diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index c429039dd..5bfe095ce 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -248,7 +248,9 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code) } if (m_pool.coin().isValid()) { - job.setAlgorithm(m_pool.coin().algorithm(job.blob()[0])); + uint8_t blobVersion = 0; + Cvt::fromHex(&blobVersion, 1, m_blockhashingblob.data(), 2); + job.setAlgorithm(m_pool.coin().algorithm(blobVersion)); } if (blocktemplate.isNull() || !job.setBlob(m_blockhashingblob)) { diff --git a/src/base/net/stratum/SelfSelectClient.cpp b/src/base/net/stratum/SelfSelectClient.cpp index 7f7ee5447..a902e252f 100644 --- a/src/base/net/stratum/SelfSelectClient.cpp +++ b/src/base/net/stratum/SelfSelectClient.cpp @@ -130,12 +130,17 @@ bool xmrig::SelfSelectClient::parseResponse(int64_t id, rapidjson::Value &result } } - if (!m_job.setBlob(result[kBlockhashingBlob].GetString())) { - return false; + const char *blobData = Json::getString(result, kBlockhashingBlob); + if (pool().coin().isValid()) { + uint8_t blobVersion = 0; + if (blobData) { + Cvt::fromHex(&blobVersion, 1, blobData, 2); + } + m_job.setAlgorithm(pool().coin().algorithm(blobVersion)); } - if (pool().coin().isValid()) { - m_job.setAlgorithm(pool().coin().algorithm(m_job.blob()[0])); + if (!m_job.setBlob(blobData)) { + return false; } m_job.setHeight(Json::getUint64(result, kHeight));