Skip to content

Commit 464c313

Browse files
committed
init: Use existing chainman
1 parent 1704bbf commit 464c313

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/init.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,8 +1384,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
13841384

13851385
// If the loaded chain has a wrong genesis, bail out immediately
13861386
// (we're likely using a testnet datadir, or the other way around).
1387+
assert(std::addressof(g_chainman.m_blockman) == std::addressof(chainman.m_blockman));
13871388
if (!chainman.BlockIndex().empty() &&
1388-
!g_chainman.m_blockman.LookupBlockIndex(chainparams.GetConsensus().hashGenesisBlock)) {
1389+
!chainman.m_blockman.LookupBlockIndex(chainparams.GetConsensus().hashGenesisBlock)) {
13891390
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
13901391
}
13911392

@@ -1400,7 +1401,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14001401
// If we're not mid-reindex (based on disk + args), add a genesis block on disk
14011402
// (otherwise we use the one already on disk).
14021403
// This is called again in ThreadImport after the reindex completes.
1403-
if (!fReindex && !::ChainstateActive().LoadGenesisBlock(chainparams)) {
1404+
if (!fReindex && !chainman.ActiveChainstate().LoadGenesisBlock(chainparams)) {
14041405
strLoadError = _("Error initializing block database");
14051406
break;
14061407
}
@@ -1549,21 +1550,21 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15491550
// ********************************************************* Step 8: start indexers
15501551
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
15511552
g_txindex = std::make_unique<TxIndex>(nTxIndexCache, false, fReindex);
1552-
if (!g_txindex->Start(::ChainstateActive())) {
1553+
if (!g_txindex->Start(chainman.ActiveChainstate())) {
15531554
return false;
15541555
}
15551556
}
15561557

15571558
for (const auto& filter_type : g_enabled_filter_types) {
15581559
InitBlockFilterIndex(filter_type, filter_index_cache, false, fReindex);
1559-
if (!GetBlockFilterIndex(filter_type)->Start(::ChainstateActive())) {
1560+
if (!GetBlockFilterIndex(filter_type)->Start(chainman.ActiveChainstate())) {
15601561
return false;
15611562
}
15621563
}
15631564

15641565
if (args.GetBoolArg("-coinstatsindex", DEFAULT_COINSTATSINDEX)) {
15651566
g_coin_stats_index = std::make_unique<CoinStatsIndex>(/* cache size */ 0, false, fReindex);
1566-
if (!g_coin_stats_index->Start(::ChainstateActive())) {
1567+
if (!g_coin_stats_index->Start(chainman.ActiveChainstate())) {
15671568
return false;
15681569
}
15691570
}
@@ -1611,7 +1612,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
16111612
// Either install a handler to notify us when genesis activates, or set fHaveGenesis directly.
16121613
// No locking, as this happens before any background thread is started.
16131614
boost::signals2::connection block_notify_genesis_wait_connection;
1614-
if (::ChainActive().Tip() == nullptr) {
1615+
assert(std::addressof(::ChainActive()) == std::addressof(chainman.ActiveChain()));
1616+
if (chainman.ActiveChain().Tip() == nullptr) {
16151617
block_notify_genesis_wait_connection = uiInterface.NotifyBlockTip_connect(std::bind(BlockNotifyGenesisWait, std::placeholders::_2));
16161618
} else {
16171619
fHaveGenesis = true;

0 commit comments

Comments
 (0)