mirror of https://github.com/bitcoin/bitcoin
refactor: init, simplify index shutdown code
This commit is contained in:
parent
0faafb57f8
commit
99afb9d15a
21
src/init.cpp
21
src/init.cpp
|
@ -256,12 +256,8 @@ void Interrupt(NodeContext& node)
|
||||||
InterruptMapPort();
|
InterruptMapPort();
|
||||||
if (node.connman)
|
if (node.connman)
|
||||||
node.connman->Interrupt();
|
node.connman->Interrupt();
|
||||||
if (g_txindex) {
|
for (auto* index : node.indexes) {
|
||||||
g_txindex->Interrupt();
|
index->Interrupt();
|
||||||
}
|
|
||||||
ForEachBlockFilterIndex([](BlockFilterIndex& index) { index.Interrupt(); });
|
|
||||||
if (g_coin_stats_index) {
|
|
||||||
g_coin_stats_index->Interrupt();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,16 +333,11 @@ void Shutdown(NodeContext& node)
|
||||||
if (node.validation_signals) node.validation_signals->FlushBackgroundCallbacks();
|
if (node.validation_signals) node.validation_signals->FlushBackgroundCallbacks();
|
||||||
|
|
||||||
// Stop and delete all indexes only after flushing background callbacks.
|
// Stop and delete all indexes only after flushing background callbacks.
|
||||||
if (g_txindex) {
|
for (auto* index : node.indexes) index->Stop();
|
||||||
g_txindex->Stop();
|
if (g_txindex) g_txindex.reset();
|
||||||
g_txindex.reset();
|
if (g_coin_stats_index) g_coin_stats_index.reset();
|
||||||
}
|
|
||||||
if (g_coin_stats_index) {
|
|
||||||
g_coin_stats_index->Stop();
|
|
||||||
g_coin_stats_index.reset();
|
|
||||||
}
|
|
||||||
ForEachBlockFilterIndex([](BlockFilterIndex& index) { index.Stop(); });
|
|
||||||
DestroyAllBlockFilterIndexes();
|
DestroyAllBlockFilterIndexes();
|
||||||
|
node.indexes.clear(); // all instances are nullptr now
|
||||||
|
|
||||||
// Any future callbacks will be dropped. This should absolutely be safe - if
|
// Any future callbacks will be dropped. This should absolutely be safe - if
|
||||||
// missing a callback results in an unrecoverable situation, unclean shutdown
|
// missing a callback results in an unrecoverable situation, unclean shutdown
|
||||||
|
|
Loading…
Reference in New Issue