Fixed missing blocks download logic

This commit is contained in:
SChernykh 2022-05-12 08:49:34 +02:00
parent 5cea7be405
commit eb3a3872eb
2 changed files with 4 additions and 1 deletions

View file

@ -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()

View file

@ -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);
}