Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,982 Lines • ▼ Show 20 Lines | if (index->pprev && index->pprev->IsValid(BlockValidity::TRANSACTIONS) && | ||||
index->pprev->HaveTxsDownloaded()) { | index->pprev->HaveTxsDownloaded()) { | ||||
setBlockIndexCandidates.insert(index->pprev); | setBlockIndexCandidates.insert(index->pprev); | ||||
} | } | ||||
} | } | ||||
bool CChainState::RewindBlockIndex(const Config &config) { | bool CChainState::RewindBlockIndex(const Config &config) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
// 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); | |||||
} | |||||
} | |||||
deadalnix: That loop doesn't correspond tot he loop that exist in the source material. The loop in the… | |||||
const CChainParams ¶ms = config.GetChainParams(); | const CChainParams ¶ms = config.GetChainParams(); | ||||
int nHeight = chainActive.Height() + 1; | int nHeight = chainActive.Height() + 1; | ||||
// nHeight is now the height of the first insufficiently-validated block, or | // nHeight is now the height of the first insufficiently-validated block, or | ||||
// tipheight + 1 | // tipheight + 1 | ||||
CValidationState state; | CValidationState state; | ||||
CBlockIndex *pindex = chainActive.Tip(); | CBlockIndex *pindex = chainActive.Tip(); | ||||
while (chainActive.Height() >= nHeight) { | while (chainActive.Height() >= nHeight) { | ||||
Show All 14 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); | |||||
} | |||||
} | |||||
deadalnixUnsubmitted Not Done Inline ActionsYou can probably simply remove this loop. deadalnix: You can probably simply remove this loop. | |||||
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 |
That loop doesn't correspond tot he loop that exist in the source material. The loop in the source material is supposed to clear segwit blocks that have been downloaded by a node using a pre segwit version.