Fixed many "new job" messages when solo mining

Fix for https://github.com/xmrig/xmrig/issues/2127
This commit is contained in:
SChernykh 2021-03-01 17:46:05 +01:00
parent 0b7dfaabe0
commit 91ad6fcf3d
2 changed files with 24 additions and 4 deletions

View file

@ -179,12 +179,30 @@ void xmrig::DaemonClient::onHttpData(const HttpData &data)
return send(kGetInfo);
}
if (isOutdated(Json::getUint64(doc, kHeight), Json::getString(doc, kHash))) {
getBlockTemplate();
const uint64_t height = Json::getUint64(doc, kHeight);
const String hash = Json::getString(doc, kHash);
if (isOutdated(height, hash)) {
// Multiple /getheight responses can come at once resulting in multiple getBlockTemplate() calls
if ((height != m_blocktemplateRequestHeight) || (hash != m_blocktemplateRequestHash)) {
m_blocktemplateRequestHeight = height;
m_blocktemplateRequestHash = hash;
getBlockTemplate();
}
}
}
else if (data.url == kGetInfo && isOutdated(Json::getUint64(doc, kHeight), Json::getString(doc, "top_block_hash"))) {
getBlockTemplate();
else if (data.url == kGetInfo) {
const uint64_t height = Json::getUint64(doc, kHeight);
const String hash = Json::getString(doc, "top_block_hash");
if (isOutdated(height, hash)) {
// Multiple /getinfo responses can come at once resulting in multiple getBlockTemplate() calls
if ((height != m_blocktemplateRequestHeight) || (hash != m_blocktemplateRequestHash)) {
m_blocktemplateRequestHeight = height;
m_blocktemplateRequestHash = hash;
getBlockTemplate();
}
}
}
return;

View file

@ -89,6 +89,8 @@ private:
String m_tlsFingerprint;
String m_tlsVersion;
Timer *m_timer;
uint64_t m_blocktemplateRequestHeight = 0;
String m_blocktemplateRequestHash;
};