diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2023-05-17 00:55:09 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2023-07-10 10:47:17 -0300 |
commit | 430e7027a18870a296abb0bbd9332cbe40d8fdc0 (patch) | |
tree | f3eb0ea165cce9123f47bed6ff3130cbb9bb97e6 /src/init.cpp | |
parent | 225e213110602b4fd1d345167f5f92d26557f6c1 (diff) |
refactor: index, decouple 'Init' from 'Start'
So indexes can be initialized without spawning
the sync thread.
This makes asynchronous indexes startup
possible in the following commits.
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp index 7d44ccc17f..102e7932cd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1567,8 +1567,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) node.indexes.emplace_back(g_coin_stats_index.get()); } + // Init indexes + for (auto index : node.indexes) if (!index->Init()) return false; + // Now that all indexes are loaded, start them - StartIndexes(node); + if (!StartIndexBackgroundSync(node)) return false; // ********************************************************* Step 9: load wallet for (const auto& client : node.chain_clients) { @@ -1876,8 +1879,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) return true; } -bool StartIndexes(NodeContext& node) +bool StartIndexBackgroundSync(NodeContext& node) { - for (auto index : node.indexes) if (!index->Start()) return false; + for (auto index : node.indexes) if (!index->StartBackgroundSync()) return false; return true; } |