Skip to content

Commit fa4245d

Browse files
author
MarcoFalke
committed
doc: Various validation doc fixups
* Rename RewindBlockIndex -> NeedsRedownload (follow-up to commit d831e71) * Fix typos * Inline comments about faking chain data to avoid duplicating them
1 parent a83bbf0 commit fa4245d

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/chain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class CBlockIndex
182182
//!
183183
//! Note: this value is modified to show BLOCK_OPT_WITNESS during UTXO snapshot
184184
//! load to avoid the block index being spuriously rewound.
185-
//! @sa RewindBlockIndex
185+
//! @sa NeedsRedownload
186186
//! @sa ActivateSnapshot
187187
uint32_t nStatus{0};
188188

src/validation.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,8 +1401,9 @@ void CChainState::InvalidChainFound(CBlockIndex* pindexNew)
14011401
}
14021402

14031403
// Same as InvalidChainFound, above, except not called directly from InvalidateBlock,
1404-
// which does its own setBlockIndexCandidates manageent.
1405-
void CChainState::InvalidBlockFound(CBlockIndex *pindex, const BlockValidationState &state) {
1404+
// which does its own setBlockIndexCandidates management.
1405+
void CChainState::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state)
1406+
{
14061407
if (state.GetResult() != BlockValidationResult::BLOCK_MUTATED) {
14071408
pindex->nStatus |= BLOCK_FAILED_VALID;
14081409
m_blockman.m_failed_blocks.insert(pindex);
@@ -1819,8 +1820,8 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
18191820
// may have let in a block that violates the rule prior to updating the
18201821
// software, and we would NOT be enforcing the rule here. Fully solving
18211822
// upgrade from one software version to the next after a consensus rule
1822-
// change is potentially tricky and issue-specific (see RewindBlockIndex()
1823-
// for one general approach that was used for BIP 141 deployment).
1823+
// change is potentially tricky and issue-specific (see NeedsRedownload()
1824+
// for one approach that was used for BIP 141 deployment).
18241825
// Also, currently the rule against blocks more than 2 hours in the future
18251826
// is enforced in ContextualCheckBlockHeader(); we wouldn't want to
18261827
// re-enforce that rule here (at least until we make it impossible for
@@ -5079,24 +5080,20 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
50795080
LOCK(::cs_main);
50805081

50815082
// Fake various pieces of CBlockIndex state:
5082-
//
5083-
// - nChainTx: so that we accurately report IBD-to-tip progress
5084-
// - nTx: so that LoadBlockIndex() loads assumed-valid CBlockIndex entries
5085-
// (among other things)
5086-
// - nStatus & BLOCK_OPT_WITNESS: so that RewindBlockIndex() doesn't zealously
5087-
// unwind the assumed-valid chain.
5088-
//
50895083
CBlockIndex* index = nullptr;
50905084
for (int i = 0; i <= snapshot_chainstate.m_chain.Height(); ++i) {
50915085
index = snapshot_chainstate.m_chain[i];
50925086

5087+
// Fake nTx so that LoadBlockIndex() loads assumed-valid CBlockIndex
5088+
// entries (among other things)
50935089
if (!index->nTx) {
50945090
index->nTx = 1;
50955091
}
5092+
// Fake nChainTx so that GuessVerificationProgress reports accurately
50965093
index->nChainTx = index->pprev ? index->pprev->nChainTx + index->nTx : 1;
50975094

5098-
// We need to fake this flag so that CChainState::RewindBlockIndex()
5099-
// won't try to rewind the entire assumed-valid chain on startup.
5095+
// Fake BLOCK_OPT_WITNESS so that CChainState::NeedsRedownload()
5096+
// won't ask to rewind the entire assumed-valid chain on startup.
51005097
if (index->pprev && ::IsWitnessEnabled(index->pprev, ::Params().GetConsensus())) {
51015098
index->nStatus |= BLOCK_OPT_WITNESS;
51025099
}

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ enum class CoinsCacheSizeState
555555
*
556556
* Anything that is contingent on the current tip of the chain is stored here,
557557
* whereas block information and metadata independent of the current tip is
558-
* kept in `BlockMetadataManager`.
558+
* kept in `BlockManager`.
559559
*/
560560
class CChainState
561561
{

0 commit comments

Comments
 (0)