mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-11-17 16:27:45 +00:00
Fixed autodiff when running for a long time
16-bit wrap around wasn't processed correctly
This commit is contained in:
parent
64baf660bb
commit
340a3e85c8
1 changed files with 2 additions and 2 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue