mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user