diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2023-06-16 10:16:22 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2023-07-07 19:31:27 -0300 |
commit | 225e213110602b4fd1d345167f5f92d26557f6c1 (patch) | |
tree | 7f5e352803344f9d6a43347cfc6fe225a474e04a /src/init.cpp | |
parent | 2ebc7e68cc9d347807b646f601b27940c9590c89 (diff) |
refactor: init indexes, decouple 'Start()' from the creation step
No behavior change.
The goal here is to group indexes, so we can perform the same
initialization and verification process equally for all of them.
The checks performed inside `StartIndexes` will be expanded
in the subsequent commits.
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/init.cpp b/src/init.cpp index 80205df000..7d44ccc17f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1554,25 +1554,22 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) } g_txindex = std::make_unique<TxIndex>(interfaces::MakeChain(node), cache_sizes.tx_index, false, fReindex); - if (!g_txindex->Start()) { - return false; - } + node.indexes.emplace_back(g_txindex.get()); } for (const auto& filter_type : g_enabled_filter_types) { InitBlockFilterIndex([&]{ return interfaces::MakeChain(node); }, filter_type, cache_sizes.filter_index, false, fReindex); - if (!GetBlockFilterIndex(filter_type)->Start()) { - return false; - } + node.indexes.emplace_back(GetBlockFilterIndex(filter_type)); } if (args.GetBoolArg("-coinstatsindex", DEFAULT_COINSTATSINDEX)) { g_coin_stats_index = std::make_unique<CoinStatsIndex>(interfaces::MakeChain(node), /*cache_size=*/0, false, fReindex); - if (!g_coin_stats_index->Start()) { - return false; - } + node.indexes.emplace_back(g_coin_stats_index.get()); } + // Now that all indexes are loaded, start them + StartIndexes(node); + // ********************************************************* Step 9: load wallet for (const auto& client : node.chain_clients) { if (!client->load()) { @@ -1878,3 +1875,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) return true; } + +bool StartIndexes(NodeContext& node) +{ + for (auto index : node.indexes) if (!index->Start()) return false; + return true; +} |