Skip to content

Commit 7110d45

Browse files
committed
Merge #12980: Allow quicker shutdowns during LoadBlockIndex()
af5fa82 Allow quicker shutdowns during LoadBlockIndex() (Jonas Schnelli) Pull request description: ACKs for commit af5fa8: promag: utACK af5fa82. practicalswift: utACK af5fa82 Tree-SHA512: 1c64dcc5d8a9d3411553257cd5a598dcd29be981660e5bca9283c1d957dc56798abcf41d9969cd573088137597a23e48e62a8c476c463d3f176b86a10048f47b
2 parents 387eb5b + af5fa82 commit 7110d45

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
@@ -1522,6 +1522,7 @@ bool AppInitMain(InitInterfaces& interfaces)
15221522
// Note that it also sets fReindex based on the disk flag!
15231523
// From here on out fReindex and fReset mean something different!
15241524
if (!LoadBlockIndex(chainparams)) {
1525+
if (ShutdownRequested()) break;
15251526
strLoadError = _("Error loading block database");
15261527
break;
15271528
}

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
@@ -3861,6 +3861,7 @@ bool CChainState::LoadBlockIndex(const Consensus::Params& consensus_params, CBlo
38613861
sort(vSortedByHeight.begin(), vSortedByHeight.end());
38623862
for (const std::pair<int, CBlockIndex*>& item : vSortedByHeight)
38633863
{
3864+
if (ShutdownRequested()) return false;
38643865
CBlockIndex* pindex = item.second;
38653866
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
38663867
pindex->nTimeMax = (pindex->pprev ? std::max(pindex->pprev->nTimeMax, pindex->nTime) : pindex->nTime);

0 commit comments

Comments
 (0)