Fixed autodiff when running for a long time
16-bit wrap around wasn't processed correctly
This commit is contained in:
@@ -614,14 +614,14 @@ void StratumServer::update_auto_diff(StratumClient* client, const uint64_t times
|
|||||||
|
|
||||||
if (k >= N) {
|
if (k >= N) {
|
||||||
// Full window
|
// Full window
|
||||||
const uint64_t dt = t2 - t1;
|
const uint16_t dt = t2 - t1;
|
||||||
client->m_autoDiff.lo = std::max<uint64_t>((client->m_autoDiffWindowHashes * AUTO_DIFF_TARGET_TIME) / (dt ? dt : 1), MIN_DIFF);
|
client->m_autoDiff.lo = std::max<uint64_t>((client->m_autoDiffWindowHashes * AUTO_DIFF_TARGET_TIME) / (dt ? dt : 1), MIN_DIFF);
|
||||||
client->m_autoDiff.hi = 0;
|
client->m_autoDiff.hi = 0;
|
||||||
}
|
}
|
||||||
else if (k >= 10) {
|
else if (k >= 10) {
|
||||||
// Partial window
|
// Partial window
|
||||||
const uint64_t h0 = hash_uncompress(client->m_autoDiffData[0].m_hashes);
|
const uint64_t h0 = hash_uncompress(client->m_autoDiffData[0].m_hashes);
|
||||||
const uint64_t dt = client->m_autoDiffData[k].m_timestamp - client->m_autoDiffData[0].m_timestamp;
|
const uint16_t dt = client->m_autoDiffData[k].m_timestamp - client->m_autoDiffData[0].m_timestamp;
|
||||||
|
|
||||||
client->m_autoDiff.lo = std::max<uint64_t>(((client->m_autoDiffWindowHashes - h0) * AUTO_DIFF_TARGET_TIME) / (dt ? dt : 1), MIN_DIFF);
|
client->m_autoDiff.lo = std::max<uint64_t>(((client->m_autoDiffWindowHashes - h0) * AUTO_DIFF_TARGET_TIME) / (dt ? dt : 1), MIN_DIFF);
|
||||||
client->m_autoDiff.hi = 0;
|
client->m_autoDiff.hi = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user