Skip to content

Commit 7aa7f27

Browse files
committed
validation: reset BLOCK_FAILED_CHILD to BLOCK_FAILED_VALID when loading from disk
- there maybe existing block indexes stored in disk with BLOCK_FAILED_CHILD - since they don't exist anymore, clean up block index entries with BLOCK_FAILED_CHILD and reset it to BLOCK_FAILED_VALID.
1 parent 43a85fe commit 7aa7f27

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/node/blockstorage.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,9 @@ bool BlockManager::LoadBlockIndex(const std::optional<uint256>& snapshot_blockha
462462
}
463463
}
464464
if (!(pindex->nStatus & BLOCK_FAILED_VALID) && pindex->pprev && (pindex->pprev->nStatus & BLOCK_FAILED_VALID)) {
465-
pindex->nStatus |= BLOCK_FAILED_VALID;
465+
// if BLOCK_FAILED_CHILD already exists in disk, clear it
466+
// and reset it to BLOCK_FAILED_VALID which is used everywhere now
467+
pindex->nStatus = (pindex->nStatus & ~BLOCK_FAILED_CHILD) | BLOCK_FAILED_VALID;
466468
m_dirty_blockindex.insert(pindex);
467469
}
468470
if (pindex->pprev) {

0 commit comments

Comments
 (0)