From af5fa82b676a36e60eda080ca0a946bdfffefd49 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Fri, 13 Apr 2018 21:20:29 +0200 Subject: Allow quicker shutdowns during LoadBlockIndex() --- src/init.cpp | 1 + src/txdb.cpp | 1 + src/validation.cpp | 1 + 3 files changed, 3 insertions(+) (limited to 'src') diff --git a/src/init.cpp b/src/init.cpp index 18402ef5d7..feb5ff2c5e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1468,6 +1468,7 @@ bool AppInitMain() // Note that it also sets fReindex based on the disk flag! // From here on out fReindex and fReset mean something different! if (!LoadBlockIndex(chainparams)) { + if (ShutdownRequested()) break; strLoadError = _("Error loading block database"); break; } diff --git a/src/txdb.cpp b/src/txdb.cpp index cbea550739..eda959e1a1 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -255,6 +255,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams, // Load mapBlockIndex while (pcursor->Valid()) { boost::this_thread::interruption_point(); + if (ShutdownRequested()) return false; std::pair key; if (pcursor->GetKey(key) && key.first == DB_BLOCK_INDEX) { CDiskBlockIndex diskindex; diff --git a/src/validation.cpp b/src/validation.cpp index 702a8d7e05..563cd59382 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3855,6 +3855,7 @@ bool CChainState::LoadBlockIndex(const Consensus::Params& consensus_params, CBlo sort(vSortedByHeight.begin(), vSortedByHeight.end()); for (const std::pair& item : vSortedByHeight) { + if (ShutdownRequested()) return false; CBlockIndex* pindex = item.second; pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex); pindex->nTimeMax = (pindex->pprev ? std::max(pindex->pprev->nTimeMax, pindex->nTime) : pindex->nTime); -- cgit v1.2.3