Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 5,014 Lines • ▼ Show 20 Lines | void UnloadBlockIndex() { | ||||
pindexBestForkBase = nullptr; | pindexBestForkBase = nullptr; | ||||
g_mempool.clear(); | g_mempool.clear(); | ||||
mapBlocksUnlinked.clear(); | mapBlocksUnlinked.clear(); | ||||
vinfoBlockFile.clear(); | vinfoBlockFile.clear(); | ||||
nLastBlockFile = 0; | nLastBlockFile = 0; | ||||
setDirtyBlockIndex.clear(); | setDirtyBlockIndex.clear(); | ||||
setDirtyFileInfo.clear(); | setDirtyFileInfo.clear(); | ||||
for (BlockMap::value_type &entry : mapBlockIndex) { | for (const BlockMap::value_type &entry : mapBlockIndex) { | ||||
delete entry.second; | delete entry.second; | ||||
} | } | ||||
mapBlockIndex.clear(); | mapBlockIndex.clear(); | ||||
fHavePruned = false; | fHavePruned = false; | ||||
g_chainstate.UnloadBlockIndex(); | g_chainstate.UnloadBlockIndex(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | void CChainState::CheckBlockIndex(const Consensus::Params &consensusParams) { | ||||
// require that chainActive has been initialized.) | // require that chainActive has been initialized.) | ||||
if (chainActive.Height() < 0) { | if (chainActive.Height() < 0) { | ||||
assert(mapBlockIndex.size() <= 1); | assert(mapBlockIndex.size() <= 1); | ||||
return; | return; | ||||
} | } | ||||
// Build forward-pointing map of the entire block tree. | // Build forward-pointing map of the entire block tree. | ||||
std::multimap<CBlockIndex *, CBlockIndex *> forward; | std::multimap<CBlockIndex *, CBlockIndex *> forward; | ||||
for (auto &entry : mapBlockIndex) { | for (const auto &entry : mapBlockIndex) { | ||||
forward.emplace(entry.second->pprev, entry.second); | forward.emplace(entry.second->pprev, entry.second); | ||||
} | } | ||||
assert(forward.size() == mapBlockIndex.size()); | assert(forward.size() == mapBlockIndex.size()); | ||||
std::pair<std::multimap<CBlockIndex *, CBlockIndex *>::iterator, | std::pair<std::multimap<CBlockIndex *, CBlockIndex *>::iterator, | ||||
std::multimap<CBlockIndex *, CBlockIndex *>::iterator> | std::multimap<CBlockIndex *, CBlockIndex *>::iterator> | ||||
rangeGenesis = forward.equal_range(nullptr); | rangeGenesis = forward.equal_range(nullptr); | ||||
▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines |