Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 5,013 Lines • ▼ Show 20 Lines | while (chainActive.Height() >= nHeight) { | ||||
// Occasionally flush state to disk. | // Occasionally flush state to disk. | ||||
if (!FlushStateToDisk(params, state, FlushStateMode::PERIODIC)) { | if (!FlushStateToDisk(params, state, FlushStateMode::PERIODIC)) { | ||||
LogPrintf("RewindBlockIndex: unable to flush state to disk (%s)\n", | LogPrintf("RewindBlockIndex: unable to flush state to disk (%s)\n", | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
// Reduce validity flag and have-data flags. | |||||
// We do this after actual disconnecting, otherwise we'll end up writing the | |||||
// lack of data to disk before writing the chainstate, resulting in a | |||||
// failure to continue if interrupted. | |||||
for (const auto &entry : mapBlockIndex) { | |||||
CBlockIndex *pindexIter = entry.second; | |||||
if (pindexIter->IsValid(BlockValidity::TRANSACTIONS) && | |||||
pindexIter->HaveTxsDownloaded()) { | |||||
setBlockIndexCandidates.insert(pindexIter); | |||||
} | |||||
} | |||||
if (chainActive.Tip() != nullptr) { | if (chainActive.Tip() != nullptr) { | ||||
// We can't prune block index candidates based on our tip if we have | // We can't prune block index candidates based on our tip if we have | ||||
// no tip due to chainActive being empty! | // no tip due to chainActive being empty! | ||||
PruneBlockIndexCandidates(); | PruneBlockIndexCandidates(); | ||||
CheckBlockIndex(params.GetConsensus()); | CheckBlockIndex(params.GetConsensus()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 800 Lines • Show Last 20 Lines |