Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,370 Lines • ▼ Show 20 Lines | bool CChainState::LoadBlockIndex(const Consensus::Params ¶ms, | ||||
for (const std::pair<const BlockHash, CBlockIndex *> &item : | for (const std::pair<const BlockHash, CBlockIndex *> &item : | ||||
mapBlockIndex) { | 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) { | ||||
if (ShutdownRequested()) { | |||||
return false; | |||||
} | |||||
CBlockIndex *pindex = item.second; | CBlockIndex *pindex = item.second; | ||||
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + | pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + | ||||
GetBlockProof(*pindex); | GetBlockProof(*pindex); | ||||
pindex->nTimeMax = | pindex->nTimeMax = | ||||
(pindex->pprev ? std::max(pindex->pprev->nTimeMax, pindex->nTime) | (pindex->pprev ? std::max(pindex->pprev->nTimeMax, pindex->nTime) | ||||
: pindex->nTime); | : pindex->nTime); | ||||
// We can link the chain of blocks for which we've received transactions | // We can link the chain of blocks for which we've received transactions | ||||
// at some point. Pruned nodes may have deleted the block. | // at some point. Pruned nodes may have deleted the block. | ||||
▲ Show 20 Lines • Show All 1,247 Lines • Show Last 20 Lines |