Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,367 Lines • ▼ Show 20 Lines | if (!blocktree.LoadBlockIndexGuts(config, [this](const uint256 &hash) { | ||||
return false; | return false; | ||||
} | } | ||||
boost::this_thread::interruption_point(); | boost::this_thread::interruption_point(); | ||||
// Calculate nChainWork | // Calculate nChainWork | ||||
std::vector<std::pair<int, CBlockIndex *>> vSortedByHeight; | std::vector<std::pair<int, CBlockIndex *>> vSortedByHeight; | ||||
vSortedByHeight.reserve(mapBlockIndex.size()); | vSortedByHeight.reserve(mapBlockIndex.size()); | ||||
for (const std::pair<uint256, CBlockIndex *> &item : mapBlockIndex) { | for (const std::pair<const uint256, CBlockIndex *> &item : mapBlockIndex) { | ||||
CBlockIndex *pindex = item.second; | CBlockIndex *pindex = item.second; | ||||
vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex)); | vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex)); | ||||
} | } | ||||
sort(vSortedByHeight.begin(), vSortedByHeight.end()); | sort(vSortedByHeight.begin(), vSortedByHeight.end()); | ||||
for (const std::pair<int, CBlockIndex *> &item : vSortedByHeight) { | for (const std::pair<int, CBlockIndex *> &item : vSortedByHeight) { | ||||
CBlockIndex *pindex = item.second; | CBlockIndex *pindex = item.second; | ||||
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + | pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | for (int nFile = nLastBlockFile + 1; true; nFile++) { | ||||
} else { | } else { | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
// Check presence of blk files | // Check presence of blk files | ||||
LogPrintf("Checking all blk files are present...\n"); | LogPrintf("Checking all blk files are present...\n"); | ||||
std::set<int> setBlkDataFiles; | std::set<int> setBlkDataFiles; | ||||
for (const std::pair<uint256, CBlockIndex *> &item : mapBlockIndex) { | for (const std::pair<const uint256, CBlockIndex *> &item : mapBlockIndex) { | ||||
CBlockIndex *pindex = item.second; | CBlockIndex *pindex = item.second; | ||||
if (pindex->nStatus.hasData()) { | if (pindex->nStatus.hasData()) { | ||||
setBlkDataFiles.insert(pindex->nFile); | setBlkDataFiles.insert(pindex->nFile); | ||||
} | } | ||||
} | } | ||||
for (const int i : setBlkDataFiles) { | for (const int i : setBlkDataFiles) { | ||||
CDiskBlockPos pos(i, 0); | CDiskBlockPos pos(i, 0); | ||||
▲ Show 20 Lines • Show All 1,188 Lines • Show Last 20 Lines |