Fixed missing blocks download logic

pull/166/head
SChernykh 2 years ago
parent 5cea7be405
commit eb3a3872eb

@ -209,6 +209,8 @@ struct difficulty_type
FORCEINLINE double to_double() const { return static_cast<double>(hi) * 18446744073709551616.0 + static_cast<double>(lo); }
FORCEINLINE bool empty() const { return (lo == 0) && (hi == 0); }
// Finds a 64-bit target for mining (target = 2^64 / difficulty) and rounds up the result of division
// Because of that, there's a very small chance that miners will find a hash that meets the target but is still wrong (hash * difficulty >= 2^256)
// A proper difficulty check is in check_pow()

@ -302,7 +302,8 @@ void p2pool::handle_miner_data(MinerData& data)
WriteLock lock(m_mainchainLock);
for (uint64_t h = data.height; h && (h + BLOCK_HEADERS_REQUIRED > data.height); --h) {
if (m_mainchainByHeight.find(h) == m_mainchainByHeight.end()) {
auto it = m_mainchainByHeight.find(h);
if ((it == m_mainchainByHeight.end()) || it->second.difficulty.empty()) {
LOGWARN(3, "Mainchain data for height " << h << " is missing, requesting it from monerod again");
missing_heights.push_back(h);
}

Loading…
Cancel
Save