diff options
| author | Jim Posen <[email protected]> | 2020-01-08 15:07:46 -0500 |
|---|---|---|
| committer | Jim Posen <[email protected]> | 2020-01-09 19:46:57 -0500 |
| commit | 9dd58ca611f6f2b59c25d727a4e955333525d345 (patch) | |
| tree | 1bc1aad59811a3d2987010703eda466adfce1459 /src/init.cpp | |
| parent | Merge #16963: wallet: Fix unique_ptr usage in boost::signals2 (diff) | |
| download | discoin-9dd58ca611f6f2b59c25d727a4e955333525d345.tar.xz discoin-9dd58ca611f6f2b59c25d727a4e955333525d345.zip | |
init: Stop indexes on shutdown after ChainStateFlushed callback.
Currently, the latest index state may not be committed to disk on shutdown.
Diffstat (limited to 'src/init.cpp')
| -rw-r--r-- | src/init.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/init.cpp b/src/init.cpp index dc0f2ce05..011b8d5ef 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -197,8 +197,6 @@ void Shutdown(NodeContext& node) // using the other before destroying them. if (node.peer_logic) UnregisterValidationInterface(node.peer_logic.get()); if (node.connman) node.connman->Stop(); - if (g_txindex) g_txindex->Stop(); - ForEachBlockFilterIndex([](BlockFilterIndex& index) { index.Stop(); }); StopTorControl(); @@ -212,8 +210,6 @@ void Shutdown(NodeContext& node) node.peer_logic.reset(); node.connman.reset(); node.banman.reset(); - g_txindex.reset(); - DestroyAllBlockFilterIndexes(); if (::mempool.IsLoaded() && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { DumpMempool(::mempool); @@ -246,6 +242,14 @@ void Shutdown(NodeContext& node) // CValidationInterface callbacks, flush them... GetMainSignals().FlushBackgroundCallbacks(); + // Stop and delete all indexes only after flushing background callbacks. + if (g_txindex) { + g_txindex->Stop(); + g_txindex.reset(); + } + ForEachBlockFilterIndex([](BlockFilterIndex& index) { index.Stop(); }); + DestroyAllBlockFilterIndexes(); + // Any future callbacks will be dropped. This should absolutely be safe - if // missing a callback results in an unrecoverable situation, unclean shutdown // would too. The only reason to do the above flushes is to let the wallet catch |