From 9223c2f02709cd123a6bcf1ca9709ec975b8706c Mon Sep 17 00:00:00 2001 From: SChernykh Date: Mon, 19 Sep 2022 10:33:03 +0200 Subject: [PATCH] Don't reset when pool sends the same job blob --- src/base/net/stratum/Job.cpp | 8 +++++++- src/base/net/stratum/Job.h | 1 + src/core/Miner.cpp | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index 7f5d8d3f3..7aa910bfc 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); } diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 3fb31baa5..e314a266d 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 a892345d4..9cc9092b3 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);