aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2023-07-07 17:32:54 -0400
committerRyan Ofsky <ryan@ofsky.org>2023-12-04 15:39:15 -0400
commit263b23f0082c60516acced1b03abb8e4d8f9ee46 (patch)
tree31531bde4f28187b61a3c46046c48c796e7486d3
parentafdc4c3a30c0543a837a317b643cf2737ed3178c (diff)
refactor: Remove call to ShutdownRequested from chainstate init
Use chainman.m_interrupt object instead There is no change in behavior in this commit
-rw-r--r--src/bitcoin-chainstate.cpp1
-rw-r--r--src/init.cpp1
-rw-r--r--src/node/chainstate.cpp5
-rw-r--r--src/node/chainstate.h1
4 files changed, 3 insertions, 5 deletions
diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp
index 31edb86ce2..f241bdae4d 100644
--- a/src/bitcoin-chainstate.cpp
+++ b/src/bitcoin-chainstate.cpp
@@ -132,7 +132,6 @@ int main(int argc, char* argv[])
cache_sizes.coins_db = 2 << 22;
cache_sizes.coins = (450 << 20) - (2 << 20) - (2 << 22);
node::ChainstateLoadOptions options;
- options.check_interrupt = [] { return false; };
auto [status, error] = node::LoadChainstate(chainman, cache_sizes, options);
if (status != node::ChainstateLoadStatus::SUCCESS) {
std::cerr << "Failed to load Chain state from your datadir." << std::endl;
diff --git a/src/init.cpp b/src/init.cpp
index ac52b34fc5..8bff75ec91 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1515,7 +1515,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
options.check_blocks = args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS);
options.check_level = args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL);
options.require_full_verification = args.IsArgSet("-checkblocks") || args.IsArgSet("-checklevel");
- options.check_interrupt = ShutdownRequested;
options.coins_error_cb = [] {
uiInterface.ThreadSafeMessageBox(
_("Error reading from database, shutting down."),
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp
index eb1994177a..bf1fc06b0b 100644
--- a/src/node/chainstate.cpp
+++ b/src/node/chainstate.cpp
@@ -17,6 +17,7 @@
#include <txdb.h>
#include <uint256.h>
#include <util/fs.h>
+#include <util/signalinterrupt.h>
#include <util/time.h>
#include <util/translation.h>
#include <validation.h>
@@ -55,14 +56,14 @@ static ChainstateLoadResult CompleteChainstateInitialization(
}
}
- if (options.check_interrupt && options.check_interrupt()) return {ChainstateLoadStatus::INTERRUPTED, {}};
+ if (chainman.m_interrupt) return {ChainstateLoadStatus::INTERRUPTED, {}};
// LoadBlockIndex will load m_have_pruned if we've ever removed a
// block file from disk.
// Note that it also sets fReindex global based on the disk flag!
// From here on, fReindex and options.reindex values may be different!
if (!chainman.LoadBlockIndex()) {
- if (options.check_interrupt && options.check_interrupt()) return {ChainstateLoadStatus::INTERRUPTED, {}};
+ if (chainman.m_interrupt) return {ChainstateLoadStatus::INTERRUPTED, {}};
return {ChainstateLoadStatus::FAILURE, _("Error loading block database")};
}
diff --git a/src/node/chainstate.h b/src/node/chainstate.h
index 2e35035c28..a6e9a0331b 100644
--- a/src/node/chainstate.h
+++ b/src/node/chainstate.h
@@ -32,7 +32,6 @@ struct ChainstateLoadOptions {
bool require_full_verification{true};
int64_t check_blocks{DEFAULT_CHECKBLOCKS};
int64_t check_level{DEFAULT_CHECKLEVEL};
- std::function<bool()> check_interrupt;
std::function<void()> coins_error_cb;
};