Merge pull request #3126 from SChernykh/dev

Don't reset when pool sends the same job blob
This commit is contained in:
xmrig 2022-09-19 19:03:17 +07:00 committed by GitHub
commit b5de214ff9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 7 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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);