diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index 4941ca3a0..7ee0228b4 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -37,6 +37,7 @@ #endif +#include "base/io/json/Json.h" #include "base/io/json/JsonRequest.h" #include "base/io/log/Log.h" #include "base/kernel/interfaces/IClientListener.h" @@ -344,21 +345,8 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code) } } - if (params.HasMember("seed_hash")) { - const rapidjson::Value &variant = params["seed_hash"]; - - if (variant.IsString()) { - job.setSeedHash(variant.GetString()); - } - } - - if (params.HasMember("height")) { - const rapidjson::Value &variant = params["height"]; - - if (variant.IsUint64()) { - job.setHeight(variant.GetUint64()); - } - } + job.setSeedHash(Json::getString(params, "seed_hash")); + job.setHeight(Json::getUint64(params, "height")); if (!verifyAlgorithm(job.algorithm())) { *code = 6; diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index e63c3271d..70cc9151d 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -221,7 +221,6 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code) } job.setSeedHash(Json::getString(params, "seed_hash")); - job.setHeight(Json::getUint64(params, kHeight)); job.setDiff(Json::getUint64(params, "difficulty")); job.setId(blocktemplate.data() + blocktemplate.size() - 32); diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index 36098bfe9..b4ebb2c03 100644 --- a/src/base/net/stratum/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -42,8 +42,8 @@ xmrig::Job::Job() : m_diff(0), m_height(0), m_target(0), - m_seedHash(), - m_blob() + m_blob(), + m_seedHash() { } @@ -59,8 +59,8 @@ xmrig::Job::Job(int poolId, bool nicehash, const Algorithm &algorithm, const Str m_diff(0), m_height(0), m_target(0), - m_seedHash(), - m_blob() + m_blob(), + m_seedHash() { } @@ -113,6 +113,20 @@ bool xmrig::Job::setBlob(const char *blob) } +bool xmrig::Job::setSeedHash(const char *hash) +{ + if (!hash || (strlen(hash) != sizeof(m_seedHash) * 2)) { + return false; + } + +# ifdef XMRIG_PROXY_PROJECT + m_rawSeedHash = hash; +# endif + + return Buffer::fromHex(hash, sizeof(m_seedHash) * 2, m_seedHash); +} + + bool xmrig::Job::setTarget(const char *target) { if (!target) { @@ -177,15 +191,6 @@ void xmrig::Job::setDiff(uint64_t diff) } -bool xmrig::Job::setSeedHash(const char *hash) -{ - if (!hash || (strlen(hash) != sizeof(m_seedHash) * 2)) - return false; - - return Buffer::fromHex(hash, sizeof(m_seedHash) * 2, m_seedHash); -} - - xmrig::Variant xmrig::Job::variant() const { switch (m_algorithm.algo()) { diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 6b63fd14c..bc0ec2ebd 100644 --- a/src/base/net/stratum/Job.h +++ b/src/base/net/stratum/Job.h @@ -52,10 +52,10 @@ public: bool isEqual(const Job &other) const; bool setBlob(const char *blob); + bool setSeedHash(const char *hash); bool setTarget(const char *target); void setAlgorithm(const char *algo); void setDiff(uint64_t diff); - bool setSeedHash(const char *hash); inline bool isNicehash() const { return m_nicehash; } inline bool isValid() const { return m_size > 0 && m_diff > 0; } @@ -65,7 +65,7 @@ public: inline const String &id() const { return m_id; } inline const uint32_t *nonce() const { return reinterpret_cast(m_blob + 39); } inline const uint8_t *blob() const { return m_blob; } - inline const uint8_t *seed_hash() const { return m_seedHash; } + inline const uint8_t *seedHash() const { return m_seedHash; } inline int poolId() const { return m_poolId; } inline int threadId() const { return m_threadId; } inline size_t size() const { return m_size; } @@ -83,9 +83,10 @@ public: inline void setVariant(int variant) { m_algorithm.parseVariant(variant); } # ifdef XMRIG_PROXY_PROJECT - inline char *rawBlob() { return m_rawBlob; } - inline const char *rawBlob() const { return m_rawBlob; } - inline const char *rawTarget() const { return m_rawTarget; } + inline char *rawBlob() { return m_rawBlob; } + inline const char *rawBlob() const { return m_rawBlob; } + inline const char *rawTarget() const { return m_rawTarget; } + inline const String &rawSeedHash() const { return m_rawSeedHash; } # endif static inline uint32_t *nonce(uint8_t *blob) { return reinterpret_cast(blob + 39); } @@ -108,12 +109,13 @@ private: uint64_t m_diff; uint64_t m_height; uint64_t m_target; - uint8_t m_seedHash[32]; uint8_t m_blob[kMaxBlobSize]; + uint8_t m_seedHash[32]; # ifdef XMRIG_PROXY_PROJECT char m_rawBlob[kMaxBlobSize * 2 + 8]; char m_rawTarget[24]; + String m_rawSeedHash; # endif }; diff --git a/src/workers/MultiWorker.cpp b/src/workers/MultiWorker.cpp index e1ef12b25..d17a2c2e9 100644 --- a/src/workers/MultiWorker.cpp +++ b/src/workers/MultiWorker.cpp @@ -164,7 +164,7 @@ void MultiWorker::start() # ifdef XMRIG_ALGO_RANDOMX if (v == xmrig::VARIANT_RX_WOW) { allocateRandomX_VM(); - Workers::updateDataset(m_state.job.seed_hash(), m_totalWays); + Workers::updateDataset(m_state.job.seedHash(), m_totalWays); randomx_calculate_hash(m_rx_vm, m_state.blob, m_state.job.size(), m_hash); } else