@@ -3295,7 +3295,7 @@ CBlockIndex* Chainstate::FindMostWorkChain()
3295
3295
// which block files have been deleted. Remove those as candidates
3296
3296
// for the most work chain if we come across them; we can't switch
3297
3297
// to a chain unless we have all the non-active-chain parent blocks.
3298
- bool fFailedChain = pindexTest->nStatus & BLOCK_FAILED_MASK ;
3298
+ bool fFailedChain = pindexTest->nStatus & BLOCK_FAILED_VALID ;
3299
3299
bool fMissingData = !(pindexTest->nStatus & BLOCK_HAVE_DATA);
3300
3300
if (fFailedChain || fMissingData ) {
3301
3301
// Candidate chain is not usable (either invalid or missing data)
@@ -3816,7 +3816,7 @@ void Chainstate::SetBlockFailureFlags(CBlockIndex* invalid_block)
3816
3816
AssertLockHeld (cs_main);
3817
3817
3818
3818
for (auto & [_, block_index] : m_blockman.m_block_index ) {
3819
- if (block_index.GetAncestor (invalid_block->nHeight ) == invalid_block && !(block_index.nStatus & BLOCK_FAILED_MASK )) {
3819
+ if (block_index.GetAncestor (invalid_block->nHeight ) == invalid_block && !(block_index.nStatus & BLOCK_FAILED_VALID )) {
3820
3820
block_index.nStatus |= BLOCK_FAILED_VALID;
3821
3821
}
3822
3822
}
@@ -3830,7 +3830,7 @@ void Chainstate::ResetBlockFailureFlags(CBlockIndex *pindex) {
3830
3830
// Remove the invalidity flag from this block and all its descendants.
3831
3831
for (auto & [_, block_index] : m_blockman.m_block_index ) {
3832
3832
if (!block_index.IsValid () && block_index.GetAncestor (nHeight) == pindex) {
3833
- block_index.nStatus &= ~BLOCK_FAILED_MASK ;
3833
+ block_index.nStatus &= ~BLOCK_FAILED_VALID ;
3834
3834
m_blockman.m_dirty_blockindex .insert (&block_index);
3835
3835
if (block_index.IsValid (BLOCK_VALID_TRANSACTIONS) && block_index.HaveNumChainTxs () && setBlockIndexCandidates.value_comp ()(m_chain.Tip (), &block_index)) {
3836
3836
setBlockIndexCandidates.insert (&block_index);
@@ -3845,8 +3845,8 @@ void Chainstate::ResetBlockFailureFlags(CBlockIndex *pindex) {
3845
3845
3846
3846
// Remove the invalidity flag from all ancestors too.
3847
3847
while (pindex != nullptr ) {
3848
- if (pindex->nStatus & BLOCK_FAILED_MASK ) {
3849
- pindex->nStatus &= ~BLOCK_FAILED_MASK ;
3848
+ if (pindex->nStatus & BLOCK_FAILED_VALID ) {
3849
+ pindex->nStatus &= ~BLOCK_FAILED_VALID ;
3850
3850
m_blockman.m_dirty_blockindex .insert (pindex);
3851
3851
m_chainman.m_failed_blocks .erase (pindex);
3852
3852
}
@@ -4324,7 +4324,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
4324
4324
CBlockIndex* pindex = &(miSelf->second );
4325
4325
if (ppindex)
4326
4326
*ppindex = pindex;
4327
- if (pindex->nStatus & BLOCK_FAILED_MASK ) {
4327
+ if (pindex->nStatus & BLOCK_FAILED_VALID ) {
4328
4328
LogDebug (BCLog::VALIDATION, " %s: block %s is marked invalid\n " , __func__, hash.ToString ());
4329
4329
return state.Invalid (BlockValidationResult::BLOCK_CACHED_INVALID, " duplicate-invalid" );
4330
4330
}
@@ -4344,7 +4344,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
4344
4344
return state.Invalid (BlockValidationResult::BLOCK_MISSING_PREV, " prev-blk-not-found" );
4345
4345
}
4346
4346
pindexPrev = &((*mi).second );
4347
- if (pindexPrev->nStatus & BLOCK_FAILED_MASK ) {
4347
+ if (pindexPrev->nStatus & BLOCK_FAILED_VALID ) {
4348
4348
LogDebug (BCLog::VALIDATION, " header %s has prev block invalid: %s\n " , hash.ToString (), block.hashPrevBlock .ToString ());
4349
4349
return state.Invalid (BlockValidationResult::BLOCK_INVALID_PREV, " bad-prevblk" );
4350
4350
}
@@ -5027,7 +5027,7 @@ bool ChainstateManager::LoadBlockIndex()
5027
5027
chainstate->TryAddBlockIndexCandidate (pindex);
5028
5028
}
5029
5029
}
5030
- if (pindex->nStatus & BLOCK_FAILED_MASK && (!m_best_invalid || pindex->nChainWork > m_best_invalid->nChainWork )) {
5030
+ if (pindex->nStatus & BLOCK_FAILED_VALID && (!m_best_invalid || pindex->nChainWork > m_best_invalid->nChainWork )) {
5031
5031
m_best_invalid = pindex;
5032
5032
}
5033
5033
if (pindex->IsValid (BLOCK_VALID_TREE) && (m_best_header == nullptr || CBlockIndexWorkComparator ()(m_best_header, pindex)))
@@ -5388,7 +5388,7 @@ void ChainstateManager::CheckBlockIndex()
5388
5388
if ((pindex->nStatus & BLOCK_VALID_MASK) >= BLOCK_VALID_SCRIPTS) assert (pindexFirstNotScriptsValid == nullptr ); // SCRIPTS valid implies all parents are SCRIPTS valid
5389
5389
if (pindexFirstInvalid == nullptr ) {
5390
5390
// Checks for not-invalid blocks.
5391
- assert ((pindex->nStatus & BLOCK_FAILED_MASK ) == 0 ); // The failed mask cannot be set for blocks without invalid parents.
5391
+ assert ((pindex->nStatus & BLOCK_FAILED_VALID ) == 0 ); // The failed mask cannot be set for blocks without invalid parents.
5392
5392
}
5393
5393
// Make sure m_chain_tx_count sum is correctly computed.
5394
5394
if (!pindex->pprev ) {
@@ -5735,7 +5735,7 @@ util::Result<CBlockIndex*> ChainstateManager::ActivateSnapshot(
5735
5735
base_blockhash.ToString ()))};
5736
5736
}
5737
5737
5738
- bool start_block_invalid = snapshot_start_block->nStatus & BLOCK_FAILED_MASK ;
5738
+ bool start_block_invalid = snapshot_start_block->nStatus & BLOCK_FAILED_VALID ;
5739
5739
if (start_block_invalid) {
5740
5740
return util::Error{Untranslated (strprintf (" The base block header (%s) is part of an invalid chain" , base_blockhash.ToString ()))};
5741
5741
}
@@ -6448,7 +6448,7 @@ void ChainstateManager::RecalculateBestHeader()
6448
6448
AssertLockHeld (cs_main);
6449
6449
m_best_header = ActiveChain ().Tip ();
6450
6450
for (auto & entry : m_blockman.m_block_index ) {
6451
- if (!(entry.second .nStatus & BLOCK_FAILED_MASK ) && m_best_header->nChainWork < entry.second .nChainWork ) {
6451
+ if (!(entry.second .nStatus & BLOCK_FAILED_VALID ) && m_best_header->nChainWork < entry.second .nChainWork ) {
6452
6452
m_best_header = &entry.second ;
6453
6453
}
6454
6454
}
0 commit comments