diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index 7f5d8d3f..56f5de80 100644 --- a/src/base/net/stratum/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -48,7 +48,13 @@ xmrig::Job::Job(bool nicehash, const Algorithm &algorithm, const String &clientI bool xmrig::Job::isEqual(const Job &other) const { - return m_id == other.m_id && m_clientId == other.m_clientId && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0 && m_target == other.m_target; + return m_id == other.m_id && m_clientId == other.m_clientId && isEqualBlob(other) && m_target == other.m_target; +} + + +bool xmrig::Job::isEqualBlob(const Job &other) const +{ + return (m_size == other.m_size) && (memcmp(m_blob, other.m_blob, m_size) == 0); } @@ -58,19 +64,19 @@ bool xmrig::Job::setBlob(const char *blob) return false; } - m_size = strlen(blob); - if (m_size % 2 != 0) { + size_t size = strlen(blob); + if (size % 2 != 0) { return false; } - m_size /= 2; + size /= 2; const size_t minSize = nonceOffset() + nonceSize(); - if (m_size < minSize || m_size >= sizeof(m_blob)) { + if (size < minSize || size >= sizeof(m_blob)) { return false; } - if (!Cvt::fromHex(m_blob, sizeof(m_blob), blob, m_size * 2)) { + if (!Cvt::fromHex(m_blob, sizeof(m_blob), blob, size * 2)) { return false; } @@ -80,9 +86,10 @@ bool xmrig::Job::setBlob(const char *blob) # ifdef XMRIG_PROXY_PROJECT memset(m_rawBlob, 0, sizeof(m_rawBlob)); - memcpy(m_rawBlob, blob, m_size * 2); + memcpy(m_rawBlob, blob, size * 2); # endif + m_size = size; return true; } diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 3fb31baa..e314a266 100644 --- a/src/base/net/stratum/Job.h +++ b/src/base/net/stratum/Job.h @@ -59,6 +59,7 @@ public: ~Job() = default; bool isEqual(const Job &other) const; + bool isEqualBlob(const Job &other) const; bool setBlob(const char *blob); bool setSeedHash(const char *hash); bool setTarget(const char *target); diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index a892345d..9cc9092b 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -561,6 +561,12 @@ void xmrig::Miner::setJob(const Job &job, bool donate) const uint8_t index = donate ? 1 : 0; d_ptr->reset = !(d_ptr->job.index() == 1 && index == 0 && d_ptr->userJobId == job.id()); + + // Don't reset nonce if pool sends the same hashing blob again, but with different difficulty (for example) + if (d_ptr->job.isEqualBlob(job)) { + d_ptr->reset = false; + } + d_ptr->job = job; d_ptr->job.setIndex(index);