mirror of https://github.com/SChernykh/p2pool
Fixed possible sidechain split during RandomX epoch change
parent
39ba5c4131
commit
285560e120
|
@ -355,6 +355,12 @@ bool SideChain::block_seen(const PoolBlock& block)
|
||||||
return !m_seenBlocks.insert(block.m_sidechainId).second;
|
return !m_seenBlocks.insert(block.m_sidechainId).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SideChain::unsee_block(const PoolBlock& block)
|
||||||
|
{
|
||||||
|
MutexLock lock(m_sidechainLock);
|
||||||
|
m_seenBlocks.erase(block.m_sidechainId);
|
||||||
|
}
|
||||||
|
|
||||||
extern const char* BLOCK_FOUND;
|
extern const char* BLOCK_FOUND;
|
||||||
|
|
||||||
bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_blocks)
|
bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_blocks)
|
||||||
|
@ -407,13 +413,15 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
|
||||||
hash seed;
|
hash seed;
|
||||||
if (!m_pool->get_seed(block.m_txinGenHeight, seed)) {
|
if (!m_pool->get_seed(block.m_txinGenHeight, seed)) {
|
||||||
LOGWARN(3, "add_external_block: couldn't get seed hash for mainchain height " << block.m_txinGenHeight);
|
LOGWARN(3, "add_external_block: couldn't get seed hash for mainchain height " << block.m_txinGenHeight);
|
||||||
|
unsee_block(block);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash pow_hash;
|
hash pow_hash;
|
||||||
if (!block.get_pow_hash(m_pool->hasher(), seed, pow_hash)) {
|
if (!block.get_pow_hash(m_pool->hasher(), seed, pow_hash)) {
|
||||||
LOGWARN(3, "add_external_block: couldn't get PoW hash for height = " << block.m_sidechainHeight << ", mainchain height " << block.m_txinGenHeight);
|
LOGWARN(3, "add_external_block: couldn't get PoW hash for height = " << block.m_sidechainHeight << ", mainchain height " << block.m_txinGenHeight << ". Ignoring it.");
|
||||||
return false;
|
unsee_block(block);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if it has the correct parent and difficulty to go right to monerod for checking
|
// Check if it has the correct parent and difficulty to go right to monerod for checking
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
void fill_sidechain_data(PoolBlock& block, Wallet* w, const hash& txkeySec, std::vector<MinerShare>& shares);
|
void fill_sidechain_data(PoolBlock& block, Wallet* w, const hash& txkeySec, std::vector<MinerShare>& shares);
|
||||||
|
|
||||||
bool block_seen(const PoolBlock& block);
|
bool block_seen(const PoolBlock& block);
|
||||||
|
void unsee_block(const PoolBlock& block);
|
||||||
bool add_external_block(PoolBlock& block, std::vector<hash>& missing_blocks);
|
bool add_external_block(PoolBlock& block, std::vector<hash>& missing_blocks);
|
||||||
void add_block(const PoolBlock& block);
|
void add_block(const PoolBlock& block);
|
||||||
void get_missing_blocks(std::vector<hash>& missing_blocks);
|
void get_missing_blocks(std::vector<hash>& missing_blocks);
|
||||||
|
|
Loading…
Reference in New Issue