mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-03 22:03:01 +01:00
Move m_failed_blocks to ChainstateManager
The member is unrelated to block storage (BlockManager). It is related to validation. Fix the confusion by moving it. Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
This commit is contained in:
@@ -1291,7 +1291,7 @@ void CChainState::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationSt
|
||||
{
|
||||
if (state.GetResult() != BlockValidationResult::BLOCK_MUTATED) {
|
||||
pindex->nStatus |= BLOCK_FAILED_VALID;
|
||||
m_blockman.m_failed_blocks.insert(pindex);
|
||||
m_chainman.m_failed_blocks.insert(pindex);
|
||||
setDirtyBlockIndex.insert(pindex);
|
||||
setBlockIndexCandidates.erase(pindex);
|
||||
InvalidChainFound(pindex);
|
||||
@@ -2844,7 +2844,7 @@ bool CChainState::InvalidateBlock(BlockValidationState& state, CBlockIndex* pind
|
||||
to_mark_failed->nStatus |= BLOCK_FAILED_VALID;
|
||||
setDirtyBlockIndex.insert(to_mark_failed);
|
||||
setBlockIndexCandidates.erase(to_mark_failed);
|
||||
m_blockman.m_failed_blocks.insert(to_mark_failed);
|
||||
m_chainman.m_failed_blocks.insert(to_mark_failed);
|
||||
|
||||
// If any new blocks somehow arrived while we were disconnecting
|
||||
// (above), then the pre-calculation of what should go into
|
||||
@@ -2889,7 +2889,7 @@ void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
|
||||
// Reset invalid block marker if it was pointing to one of those.
|
||||
pindexBestInvalid = nullptr;
|
||||
}
|
||||
m_blockman.m_failed_blocks.erase(it->second);
|
||||
m_chainman.m_failed_blocks.erase(it->second);
|
||||
}
|
||||
it++;
|
||||
}
|
||||
@@ -2899,7 +2899,7 @@ void CChainState::ResetBlockFailureFlags(CBlockIndex *pindex) {
|
||||
if (pindex->nStatus & BLOCK_FAILED_MASK) {
|
||||
pindex->nStatus &= ~BLOCK_FAILED_MASK;
|
||||
setDirtyBlockIndex.insert(pindex);
|
||||
m_blockman.m_failed_blocks.erase(pindex);
|
||||
m_chainman.m_failed_blocks.erase(pindex);
|
||||
}
|
||||
pindex = pindex->pprev;
|
||||
}
|
||||
@@ -3325,7 +3325,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
|
||||
// hasn't been validated up to BLOCK_VALID_SCRIPTS. This is a performance
|
||||
// optimization, in the common case of adding a new block to the tip,
|
||||
// we don't need to iterate over the failed blocks list.
|
||||
for (const CBlockIndex* failedit : m_blockman.m_failed_blocks) {
|
||||
for (const CBlockIndex* failedit : m_failed_blocks) {
|
||||
if (pindexPrev->GetAncestor(failedit->nHeight) == failedit) {
|
||||
assert(failedit->nStatus & BLOCK_FAILED_VALID);
|
||||
CBlockIndex* invalid_walk = pindexPrev;
|
||||
@@ -3804,7 +3804,6 @@ bool BlockManager::LoadBlockIndex(
|
||||
}
|
||||
|
||||
void BlockManager::Unload() {
|
||||
m_failed_blocks.clear();
|
||||
m_blocks_unlinked.clear();
|
||||
|
||||
for (const BlockMap::value_type& entry : m_block_index) {
|
||||
@@ -5119,6 +5118,7 @@ void ChainstateManager::Unload()
|
||||
chainstate->UnloadBlockIndex();
|
||||
}
|
||||
|
||||
m_failed_blocks.clear();
|
||||
m_blockman.Unload();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user