aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2023-05-17 16:06:55 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2023-07-10 10:50:50 -0300
commitfcbdaeef4d5a63e3e5b479c6fcad730eb86fb923 (patch)
treee266b0cab828adc38232b388fd6bd3ff0538bdd7 /src/init.cpp
parent2ec89f1970935d27631bcd17b7923a79cdb1edbb (diff)
downloadbitcoin-fcbdaeef4d5a63e3e5b479c6fcad730eb86fb923.tar.xz
init: don't start indexes sync thread prematurely
By moving the 'StartIndexes()' call into the 'initload' thread, we can remove the threads active wait. Optimizing the available resources. The only difference with the current state is that now the indexes threads will only be started when they can process work and not before it.
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 102e7932cd..389654fe4f 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1570,9 +1570,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// Init indexes
for (auto index : node.indexes) if (!index->Init()) return false;
- // Now that all indexes are loaded, start them
- if (!StartIndexBackgroundSync(node)) return false;
-
// ********************************************************* Step 9: load wallet
for (const auto& client : node.chain_clients) {
if (!client->load()) {
@@ -1656,9 +1653,15 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
vImportFiles.push_back(fs::PathFromString(strFile));
}
- chainman.m_thread_load = std::thread(&util::TraceThread, "initload", [=, &chainman, &args] {
+ chainman.m_thread_load = std::thread(&util::TraceThread, "initload", [=, &chainman, &args, &node] {
// Import blocks
ImportBlocks(chainman, vImportFiles);
+ // Start indexes initial sync
+ if (!StartIndexBackgroundSync(node)) {
+ bilingual_str err_str = _("Failed to start indexes, shutting down..");
+ chainman.GetNotifications().fatalError(err_str.original, err_str);
+ return;
+ }
// Load mempool from disk
chainman.ActiveChainstate().LoadMempool(ShouldPersistMempool(args) ? MempoolPath(args) : fs::path{});
});