Skip to content

Commit 3328bc6

Browse files
committed
validation: correctly update BlockStatus for invalid block descendants
invalid_block ----------> block_index - before this commit, only if block_index is not invalid, it will mark block_index as BLOCK_FAILED_CHILD - it's possible that block_index encountered is invalid and was marked as BLOCK_FAILED_VALID previously - in this case, correctly update BlockStatus of block_index by clearing BLOCK_FAILED_VALID and then setting it to BLOCK_FAILED_CHILD
1 parent c03ff89 commit 3328bc6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/validation.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -3826,8 +3826,9 @@ void Chainstate::SetBlockFailureFlags(CBlockIndex* invalid_block)
38263826
AssertLockHeld(cs_main);
38273827

38283828
for (auto& [_, block_index] : m_blockman.m_block_index) {
3829-
if (block_index.GetAncestor(invalid_block->nHeight) == invalid_block && !(block_index.nStatus & BLOCK_FAILED_MASK)) {
3830-
block_index.nStatus |= BLOCK_FAILED_CHILD;
3829+
if (invalid_block != &block_index && block_index.GetAncestor(invalid_block->nHeight) == invalid_block) {
3830+
block_index.nStatus = (block_index.nStatus & ~BLOCK_FAILED_VALID) | BLOCK_FAILED_CHILD;
3831+
m_blockman.m_dirty_blockindex.insert(&block_index);
38313832
}
38323833
}
38333834
}

0 commit comments

Comments
 (0)