validation: remove redundant marking in FindMostWorkChain

since ed764ea, all descendants in m_block_index are required to be
marked BLOCK_FAILED_VALID when an invalid block is encountered,
as enforced by a CheckBlockIndex assert.

remove the now-redundant marking in FindMostWorkChain's inner loop,
so it is only responsible for cleaning up setBlockIndexCandidates,
not for modifying block validity state
This commit is contained in:
stratospher
2026-03-19 22:07:26 +05:30
parent c0d3d493a9
commit 1b0b3e2c2c

View File

@@ -3142,13 +3142,10 @@ CBlockIndex* Chainstate::FindMostWorkChain()
CBlockIndex *pindexFailed = pindexNew;
// Remove the entire chain from the set.
while (pindexTest != pindexFailed) {
if (fFailedChain) {
pindexFailed->nStatus |= BLOCK_FAILED_VALID;
m_blockman.m_dirty_blockindex.insert(pindexFailed);
} else if (fMissingData) {
// If we're missing data, then add back to m_blocks_unlinked,
// so that if the block arrives in the future we can try adding
// to setBlockIndexCandidates again.
if (fMissingData && !fFailedChain) {
// If we're missing data and not a descendant of an invalid block,
// then add back to m_blocks_unlinked, so that if the block arrives in the future
// we can try adding to setBlockIndexCandidates again.
m_blockman.m_blocks_unlinked.insert(
std::make_pair(pindexFailed->pprev, pindexFailed));
}