Skip to content

Commit

Permalink
SideChain: fixed a rare sync bug
Browse files Browse the repository at this point in the history
P2Pool could fail to sync if uncles of depth 3 were present at a certain depth in the chain
  • Loading branch information
SChernykh committed Apr 22, 2023
1 parent 75c1565 commit 2045aae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/side_chain.cpp
Expand Up @@ -1368,10 +1368,10 @@ void SideChain::verify(PoolBlock* block)
// Deep block
//
// Blocks in PPLNS window (m_chainWindowSize) require up to m_chainWindowSize earlier blocks to verify
// If a block is deeper than m_chainWindowSize * 2 - 1 it can't influence blocks in PPLNS window
// If a block is deeper than (m_chainWindowSize - 1) * 2 + UNCLE_BLOCK_DEPTH it can't influence blocks in PPLNS window
// Also, having so many blocks on top of this one means it was verified by the network at some point
// We skip checks in this case to make pruning possible
if (block->m_depth >= m_chainWindowSize * 2) {
if (block->m_depth > (m_chainWindowSize - 1) * 2 + UNCLE_BLOCK_DEPTH) {
LOGINFO(4, "block " << block->m_sidechainId << " skipped verification");
block->m_verified = true;
block->m_invalid = false;
Expand Down

0 comments on commit 2045aae

Please sign in to comment.