aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2023-11-28 09:02:00 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2024-03-12 11:55:04 -0300
commit99afb9d15a08d2f46739f4d2b66c63dbabd7a44e (patch)
treea56f6cdc146994f93542004a90bc90746d37a70e /src/init.cpp
parent0faafb57f8298547949cbc0044ee9e925ed887ba (diff)
refactor: init, simplify index shutdown code
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/init.cpp b/src/init.cpp
index b9a0bb732a..251ef0f8ff 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -256,12 +256,8 @@ void Interrupt(NodeContext& node)
InterruptMapPort();
if (node.connman)
node.connman->Interrupt();
- if (g_txindex) {
- g_txindex->Interrupt();
- }
- ForEachBlockFilterIndex([](BlockFilterIndex& index) { index.Interrupt(); });
- if (g_coin_stats_index) {
- g_coin_stats_index->Interrupt();
+ for (auto* index : node.indexes) {
+ index->Interrupt();
}
}
@@ -337,16 +333,11 @@ void Shutdown(NodeContext& node)
if (node.validation_signals) node.validation_signals->FlushBackgroundCallbacks();
// Stop and delete all indexes only after flushing background callbacks.
- if (g_txindex) {
- g_txindex->Stop();
- g_txindex.reset();
- }
- if (g_coin_stats_index) {
- g_coin_stats_index->Stop();
- g_coin_stats_index.reset();
- }
- ForEachBlockFilterIndex([](BlockFilterIndex& index) { index.Stop(); });
+ for (auto* index : node.indexes) index->Stop();
+ if (g_txindex) g_txindex.reset();
+ if (g_coin_stats_index) g_coin_stats_index.reset();
DestroyAllBlockFilterIndexes();
+ node.indexes.clear(); // all instances are nullptr now
// Any future callbacks will be dropped. This should absolutely be safe - if
// missing a callback results in an unrecoverable situation, unclean shutdown