mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
node/chainstate: Decouple from ShutdownRequested
This commit is contained in:
parent
fdf803d013
commit
c405492874
@ -1895,6 +1895,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
nBlockTreeDBCache,
|
nBlockTreeDBCache,
|
||||||
nCoinDBCache,
|
nCoinDBCache,
|
||||||
nCoinCacheUsage,
|
nCoinCacheUsage,
|
||||||
|
ShutdownRequested,
|
||||||
[]() {
|
[]() {
|
||||||
uiInterface.ThreadSafeMessageBox(
|
uiInterface.ThreadSafeMessageBox(
|
||||||
_("Error reading from database, shutting down."),
|
_("Error reading from database, shutting down."),
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include <chainparams.h> // for CChainParams
|
#include <chainparams.h> // for CChainParams
|
||||||
#include <deploymentstatus.h> // for DeploymentActiveAfter
|
#include <deploymentstatus.h> // for DeploymentActiveAfter
|
||||||
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
|
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
|
||||||
#include <shutdown.h> // for ShutdownRequested
|
|
||||||
#include <validation.h> // for a lot of things
|
#include <validation.h> // for a lot of things
|
||||||
|
|
||||||
#include <evo/chainhelper.h> // for CChainstateHelper
|
#include <evo/chainhelper.h> // for CChainstateHelper
|
||||||
@ -48,6 +47,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||||||
int64_t nBlockTreeDBCache,
|
int64_t nBlockTreeDBCache,
|
||||||
int64_t nCoinDBCache,
|
int64_t nCoinDBCache,
|
||||||
int64_t nCoinCacheUsage,
|
int64_t nCoinCacheUsage,
|
||||||
|
std::function<bool()> shutdown_requested,
|
||||||
std::function<void()> coins_error_cb)
|
std::function<void()> coins_error_cb)
|
||||||
{
|
{
|
||||||
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
||||||
@ -106,14 +106,14 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||||||
CleanupBlockRevFiles();
|
CleanupBlockRevFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShutdownRequested()) return ChainstateLoadingError::SHUTDOWN_PROBED;
|
if (shutdown_requested && shutdown_requested()) return ChainstateLoadingError::SHUTDOWN_PROBED;
|
||||||
|
|
||||||
// LoadBlockIndex will load m_have_pruned if we've ever removed a
|
// LoadBlockIndex will load m_have_pruned if we've ever removed a
|
||||||
// block file from disk.
|
// block file from disk.
|
||||||
// Note that it also sets fReindex based on the disk flag!
|
// Note that it also sets fReindex based on the disk flag!
|
||||||
// From here on out fReindex and fReset mean something different!
|
// From here on out fReindex and fReset mean something different!
|
||||||
if (!chainman.LoadBlockIndex()) {
|
if (!chainman.LoadBlockIndex()) {
|
||||||
if (ShutdownRequested()) return ChainstateLoadingError::SHUTDOWN_PROBED;
|
if (shutdown_requested && shutdown_requested()) return ChainstateLoadingError::SHUTDOWN_PROBED;
|
||||||
return ChainstateLoadingError::ERROR_LOADING_BLOCK_DB;
|
return ChainstateLoadingError::ERROR_LOADING_BLOCK_DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,10 +70,10 @@ enum class ChainstateLoadingError {
|
|||||||
* differentiable by the specific enumerator.
|
* differentiable by the specific enumerator.
|
||||||
*
|
*
|
||||||
* Note that a return value of SHUTDOWN_PROBED means ONLY that "during
|
* Note that a return value of SHUTDOWN_PROBED means ONLY that "during
|
||||||
* this sequence, when we explicitly checked ShutdownRequested() at
|
* this sequence, when we explicitly checked shutdown_requested() at
|
||||||
* arbitrary points, one of those calls returned true". Therefore, a
|
* arbitrary points, one of those calls returned true". Therefore, a
|
||||||
* return value other than SHUTDOWN_PROBED does not guarantee that
|
* return value other than SHUTDOWN_PROBED does not guarantee that
|
||||||
* ShutdownRequested() hasn't been called indirectly.
|
* shutdown_requested() hasn't been called indirectly.
|
||||||
* - else
|
* - else
|
||||||
* - Success!
|
* - Success!
|
||||||
*/
|
*/
|
||||||
@ -105,6 +105,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||||||
int64_t nBlockTreeDBCache,
|
int64_t nBlockTreeDBCache,
|
||||||
int64_t nCoinDBCache,
|
int64_t nCoinDBCache,
|
||||||
int64_t nCoinCacheUsage,
|
int64_t nCoinCacheUsage,
|
||||||
|
std::function<bool()> shutdown_requested = nullptr,
|
||||||
std::function<void()> coins_error_cb = nullptr);
|
std::function<void()> coins_error_cb = nullptr);
|
||||||
|
|
||||||
enum class ChainstateLoadVerifyError {
|
enum class ChainstateLoadVerifyError {
|
||||||
|
Loading…
Reference in New Issue
Block a user