Skip to content

Commit fa22e5c

Browse files
author
MarcoFalke
committed
refactor: Remove dead code that assumed tip == nullptr
The tip is set after waiting for the genesis block.
1 parent fa2e443 commit fa22e5c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/init.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,17 +1811,17 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
18111811

18121812
// ********************************************************* Step 12: start node
18131813

1814-
//// debug print
18151814
int64_t best_block_time{};
18161815
{
1817-
LOCK(cs_main);
1816+
LOCK(chainman.GetMutex());
1817+
const auto& tip{*Assert(chainman.ActiveTip())};
18181818
LogPrintf("block tree size = %u\n", chainman.BlockIndex().size());
1819-
chain_active_height = chainman.ActiveChain().Height();
1820-
best_block_time = chainman.ActiveChain().Tip() ? chainman.ActiveChain().Tip()->GetBlockTime() : chainman.GetParams().GenesisBlock().GetBlockTime();
1819+
chain_active_height = tip.nHeight;
1820+
best_block_time = tip.GetBlockTime();
18211821
if (tip_info) {
18221822
tip_info->block_height = chain_active_height;
18231823
tip_info->block_time = best_block_time;
1824-
tip_info->verification_progress = GuessVerificationProgress(chainman.GetParams().TxData(), chainman.ActiveChain().Tip());
1824+
tip_info->verification_progress = GuessVerificationProgress(chainman.GetParams().TxData(), &tip);
18251825
}
18261826
if (tip_info && chainman.m_best_header) {
18271827
tip_info->header_height = chainman.m_best_header->nHeight;

0 commit comments

Comments
 (0)