Skip to content

Commit af5fa82

Browse files
committed
Allow quicker shutdowns during LoadBlockIndex()
1 parent f030410 commit af5fa82

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

src/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,7 @@ bool AppInitMain()
14681468
// Note that it also sets fReindex based on the disk flag!
14691469
// From here on out fReindex and fReset mean something different!
14701470
if (!LoadBlockIndex(chainparams)) {
1471+
if (ShutdownRequested()) break;
14711472
strLoadError = _("Error loading block database");
14721473
break;
14731474
}

src/txdb.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
255255
// Load mapBlockIndex
256256
while (pcursor->Valid()) {
257257
boost::this_thread::interruption_point();
258+
if (ShutdownRequested()) return false;
258259
std::pair<char, uint256> key;
259260
if (pcursor->GetKey(key) && key.first == DB_BLOCK_INDEX) {
260261
CDiskBlockIndex diskindex;

src/validation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3855,6 +3855,7 @@ bool CChainState::LoadBlockIndex(const Consensus::Params& consensus_params, CBlo
38553855
sort(vSortedByHeight.begin(), vSortedByHeight.end());
38563856
for (const std::pair<int, CBlockIndex*>& item : vSortedByHeight)
38573857
{
3858+
if (ShutdownRequested()) return false;
38583859
CBlockIndex* pindex = item.second;
38593860
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
38603861
pindex->nTimeMax = (pindex->pprev ? std::max(pindex->pprev->nTimeMax, pindex->nTime) : pindex->nTime);

0 commit comments

Comments
 (0)