SideChain: recover from incorrect PoW calculation

pull/271/head
SChernykh 2023-06-14 11:22:55 +02:00
parent 9927718e25
commit 950330b5f7
1 changed files with 9 additions and 1 deletions

View File

@ -602,13 +602,21 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
", mainchain height = " << block.m_txinGenHeight
);
bool not_enough_pow = true;
// Calculate the same hash second time to check if it's an unstable hardware that caused this
hash pow_hash2;
if (block.get_pow_hash(m_pool->hasher(), block.m_txinGenHeight, seed, pow_hash2, true) && (pow_hash2 != pow_hash)) {
LOGERR(0, "UNSTABLE HARDWARE DETECTED: Calculated the same hash twice, got different results: " << pow_hash << " != " << pow_hash2 << " (sidechain id = " << block.m_sidechainId << ')');
if (block.m_difficulty.check_pow(pow_hash2)) {
LOGINFO(3, "add_external_block second result has enough PoW for height = " << block.m_sidechainHeight << ", id = " << block.m_sidechainId);
not_enough_pow = false;
}
}
return false;
if (not_enough_pow) {
return false;
}
}
bool block_found = false;