@@ -1479,8 +1479,9 @@ void CChainState::InvalidChainFound(CBlockIndex* pindexNew)
14791479}
14801480
14811481// Same as InvalidChainFound, above, except not called directly from InvalidateBlock,
1482- // which does its own setBlockIndexCandidates manageent.
1483- void CChainState::InvalidBlockFound (CBlockIndex *pindex, const BlockValidationState &state) {
1482+ // which does its own setBlockIndexCandidates management.
1483+ void CChainState::InvalidBlockFound (CBlockIndex* pindex, const BlockValidationState& state)
1484+ {
14841485 if (state.GetResult () != BlockValidationResult::BLOCK_MUTATED) {
14851486 pindex->nStatus |= BLOCK_FAILED_VALID;
14861487 m_blockman.m_failed_blocks .insert (pindex);
@@ -1977,8 +1978,8 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
19771978 // may have let in a block that violates the rule prior to updating the
19781979 // software, and we would NOT be enforcing the rule here. Fully solving
19791980 // upgrade from one software version to the next after a consensus rule
1980- // change is potentially tricky and issue-specific (see RewindBlockIndex ()
1981- // for one general approach that was used for BIP 141 deployment).
1981+ // change is potentially tricky and issue-specific (see NeedsRedownload ()
1982+ // for one approach that was used for BIP 141 deployment).
19821983 // Also, currently the rule against blocks more than 2 hours in the future
19831984 // is enforced in ContextualCheckBlockHeader(); we wouldn't want to
19841985 // re-enforce that rule here (at least until we make it impossible for
@@ -5438,24 +5439,20 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
54385439 LOCK (::cs_main);
54395440
54405441 // Fake various pieces of CBlockIndex state:
5441- //
5442- // - nChainTx: so that we accurately report IBD-to-tip progress
5443- // - nTx: so that LoadBlockIndex() loads assumed-valid CBlockIndex entries
5444- // (among other things)
5445- // - nStatus & BLOCK_OPT_WITNESS: so that RewindBlockIndex() doesn't zealously
5446- // unwind the assumed-valid chain.
5447- //
54485442 CBlockIndex* index = nullptr ;
54495443 for (int i = 0 ; i <= snapshot_chainstate.m_chain .Height (); ++i) {
54505444 index = snapshot_chainstate.m_chain [i];
54515445
5446+ // Fake nTx so that LoadBlockIndex() loads assumed-valid CBlockIndex
5447+ // entries (among other things)
54525448 if (!index->nTx ) {
54535449 index->nTx = 1 ;
54545450 }
5451+ // Fake nChainTx so that GuessVerificationProgress reports accurately
54555452 index->nChainTx = index->pprev ? index->pprev ->nChainTx + index->nTx : 1 ;
54565453
5457- // We need to fake this flag so that CChainState::RewindBlockIndex ()
5458- // won't try to rewind the entire assumed-valid chain on startup.
5454+ // Fake BLOCK_OPT_WITNESS so that CChainState::NeedsRedownload ()
5455+ // won't ask to rewind the entire assumed-valid chain on startup.
54595456 if (index->pprev && ::IsWitnessEnabled (index->pprev , ::Params ().GetConsensus ())) {
54605457 index->nStatus |= BLOCK_OPT_WITNESS;
54615458 }
0 commit comments