mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
Fixed share effort calculation
This commit is contained in:
parent
7364292ece
commit
0558cdb9cc
1 changed files with 9 additions and 6 deletions
|
@ -541,6 +541,11 @@ void StratumServer::on_share_found(uv_work_t* req)
|
||||||
p2pool* pool = server->m_pool;
|
p2pool* pool = server->m_pool;
|
||||||
BlockTemplate& block = pool->block_template();
|
BlockTemplate& block = pool->block_template();
|
||||||
|
|
||||||
|
uint64_t target = share->m_target;
|
||||||
|
if (target >= TARGET_4_BYTES_LIMIT) {
|
||||||
|
target = (target >> 32) << 32;
|
||||||
|
}
|
||||||
|
|
||||||
if (pool->stopped()) {
|
if (pool->stopped()) {
|
||||||
LOGWARN(0, "p2pool is shutting down, but a share was found. Trying to process it anyway!");
|
LOGWARN(0, "p2pool is shutting down, but a share was found. Trying to process it anyway!");
|
||||||
}
|
}
|
||||||
|
@ -581,7 +586,10 @@ void StratumServer::on_share_found(uv_work_t* req)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t n = server->m_cumulativeHashes;
|
uint64_t rem;
|
||||||
|
const uint64_t hashes = (target > 1) ? udiv128(1, 0, target, &rem) : 0;
|
||||||
|
|
||||||
|
const uint64_t n = server->m_cumulativeHashes + hashes;
|
||||||
const double diff = sidechain_difficulty.to_double();
|
const double diff = sidechain_difficulty.to_double();
|
||||||
const double effort = static_cast<double>(n - server->m_cumulativeHashesAtLastShare) * 100.0 / diff;
|
const double effort = static_cast<double>(n - server->m_cumulativeHashesAtLastShare) * 100.0 / diff;
|
||||||
server->m_cumulativeHashesAtLastShare = n;
|
server->m_cumulativeHashesAtLastShare = n;
|
||||||
|
@ -604,11 +612,6 @@ void StratumServer::on_share_found(uv_work_t* req)
|
||||||
// Send the response to miner
|
// Send the response to miner
|
||||||
const uint64_t value = *reinterpret_cast<uint64_t*>(share->m_resultHash.h + HASH_SIZE - sizeof(uint64_t));
|
const uint64_t value = *reinterpret_cast<uint64_t*>(share->m_resultHash.h + HASH_SIZE - sizeof(uint64_t));
|
||||||
|
|
||||||
uint64_t target = share->m_target;
|
|
||||||
if (target >= TARGET_4_BYTES_LIMIT) {
|
|
||||||
target = (target >> 32) << 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LIKELY(value < target)) {
|
if (LIKELY(value < target)) {
|
||||||
server->update_hashrate_data(target);
|
server->update_hashrate_data(target);
|
||||||
share->m_result = SubmittedShare::Result::OK;
|
share->m_result = SubmittedShare::Result::OK;
|
||||||
|
|
Loading…
Reference in a new issue