Skip to content

Commit fe38ff9

Browse files
committed
bugfix: Mark all nearest BLOCK_FAILED_CHILD descendants (if any) as BLOCK_FAILED_VALID while removing the invalidity flag from all ancestors in ResetBlockFailureFlags
Fixes `Assertion failed: ((pindex->nStatus & BLOCK_FAILED_MASK) == 0), function CheckBlockIndex`
1 parent 01dc1fd commit fe38ff9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/validation.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,6 +3413,16 @@ bool CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
34133413
pindex->nStatus &= ~BLOCK_FAILED_MASK;
34143414
setDirtyBlockIndex.insert(pindex);
34153415
m_failed_blocks.erase(pindex);
3416+
// Mark all nearest BLOCK_FAILED_CHILD descendants (if any) as BLOCK_FAILED_VALID
3417+
auto itp = mapPrevBlockIndex.equal_range(pindex->GetBlockHash());
3418+
for (auto jt = itp.first; jt != itp.second; ++jt) {
3419+
if (jt->second->nStatus & BLOCK_FAILED_CHILD) {
3420+
jt->second->nStatus |= BLOCK_FAILED_VALID;
3421+
m_failed_blocks.insert(jt->second);
3422+
setDirtyBlockIndex.insert(jt->second);
3423+
setBlockIndexCandidates.erase(jt->second);
3424+
}
3425+
}
34163426
}
34173427
pindex = pindex->pprev;
34183428
}

0 commit comments

Comments
 (0)