66
77#include < chainparams.h> // for CChainParams
88#include < node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
9- #include < shutdown.h> // for ShutdownRequested
109#include < validation.h> // for a lot of things
1110
1211std::optional<ChainstateLoadingError> LoadChainstate (bool fReset ,
@@ -18,6 +17,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
1817 int64_t nBlockTreeDBCache,
1918 int64_t nCoinDBCache,
2019 int64_t nCoinCacheUsage,
20+ std::function<bool ()> shutdown_requested,
2121 std::function<void()> coins_error_cb)
2222{
2323 auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED (::cs_main) {
@@ -45,14 +45,14 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
4545 CleanupBlockRevFiles ();
4646 }
4747
48- if (ShutdownRequested ()) return ChainstateLoadingError::SHUTDOWN_PROBED;
48+ if (shutdown_requested && shutdown_requested ()) return ChainstateLoadingError::SHUTDOWN_PROBED;
4949
5050 // LoadBlockIndex will load fHavePruned if we've ever removed a
5151 // block file from disk.
5252 // Note that it also sets fReindex based on the disk flag!
5353 // From here on out fReindex and fReset mean something different!
5454 if (!chainman.LoadBlockIndex ()) {
55- if (ShutdownRequested ()) return ChainstateLoadingError::SHUTDOWN_PROBED;
55+ if (shutdown_requested && shutdown_requested ()) return ChainstateLoadingError::SHUTDOWN_PROBED;
5656 return ChainstateLoadingError::ERROR_LOADING_BLOCK_DB;
5757 }
5858
0 commit comments