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.
This commit is contained in:
1 parent
37bc207852
commit
b5b2956bda
1 file changed
+8
@@ -487,10 +487,18 @@ bool BlockManager::LoadBlockIndex(const std::optional<uint256>& snapshot_blockha
|
|||||||
pindex->m_chain_tx_count = pindex->nTx;
|
pindex->m_chain_tx_count = pindex->nTx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pindex->nStatus & BLOCK_FAILED_CHILD) {
|
||||||
|
// BLOCK_FAILED_CHILD is deprecated, but may still exist on disk. Replace it with BLOCK_FAILED_VALID.
|
||||||
|
pindex->nStatus = (pindex->nStatus & ~BLOCK_FAILED_CHILD) | BLOCK_FAILED_VALID;
|
||||||
|
m_dirty_blockindex.insert(pindex);
|
||||||
|
}
|
||||||
if (!(pindex->nStatus & BLOCK_FAILED_MASK) && pindex->pprev && (pindex->pprev->nStatus & BLOCK_FAILED_MASK)) {
|
if (!(pindex->nStatus & BLOCK_FAILED_MASK) && pindex->pprev && (pindex->pprev->nStatus & BLOCK_FAILED_MASK)) {
|
||||||
|
// All descendants of invalid blocks are invalid too.
|
||||||
pindex->nStatus |= BLOCK_FAILED_VALID;
|
pindex->nStatus |= BLOCK_FAILED_VALID;
|
||||||
m_dirty_blockindex.insert(pindex);
|
m_dirty_blockindex.insert(pindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pindex->pprev) {
|
if (pindex->pprev) {
|
||||||
pindex->BuildSkip();
|
pindex->BuildSkip();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user