MCPcopy Create free account
hub / github.com/ElementsProject/elements / IsInitialBlockDownload

Method IsInitialBlockDownload

src/validation.cpp:1575–1595  ·  view source on GitHub ↗

Note that though this is marked const, we may end up modifying `m_cached_finished_ibd`, which is a performance-related implementation detail. This function must be marked `const` so that `CValidationInterface` clients (which are given a `const CChainState*`) can call it.

Source from the content-addressed store, hash-verified

1573// can call it.
1574//
1575bool CChainState::IsInitialBlockDownload() const
1576{
1577 // Optimization: pre-test latch before taking the lock.
1578 if (m_cached_finished_ibd.load(std::memory_order_relaxed))
1579 return false;
1580
1581 LOCK(cs_main);
1582 if (m_cached_finished_ibd.load(std::memory_order_relaxed))
1583 return false;
1584 if (fImporting || fReindex)
1585 return true;
1586 if (m_chain.Tip() == nullptr)
1587 return true;
1588 if (m_chain.Tip()->nChainWork < nMinimumChainWork)
1589 return true;
1590 if (m_chain.Tip()->GetBlockTime() < (GetTime() - nMaxTipAge))
1591 return true;
1592 LogPrintf("Leaving InitialBlockDownload (latching to false)\n");
1593 m_cached_finished_ibd.store(true, std::memory_order_relaxed);
1594 return false;
1595}
1596
1597static void AlertNotify(const std::string& strMessage)
1598{

Callers 15

UpdateTipMethod · 0.95
BlockCheckedMethod · 0.80
ProcessHeadersMessageMethod · 0.80
ProcessMessageMethod · 0.80
MaybeSendAddrMethod · 0.80
MaybeSendFeefilterMethod · 0.80
SendMessagesMethod · 0.80
EXCLUSIVE_LOCKS_REQUIREDFunction · 0.80
LOCKS_EXCLUDEDFunction · 0.80
MaybeRebalanceCachesMethod · 0.80
getblocktemplateFunction · 0.80

Calls 4

GetTimeFunction · 0.85
loadMethod · 0.45
TipMethod · 0.45
GetBlockTimeMethod · 0.45

Tested by

no test coverage detected