Skip to content

Commit 99df6bf

Browse files
committed
Use m_cached_chaintip_recent in IsIBD removing the cs_main lock.
1 parent e11f608 commit 99df6bf

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

src/validation.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,26 +2015,13 @@ void Chainstate::InitCoinsCache(size_t cache_size_bytes)
20152015
//
20162016
bool ChainstateManager::IsInitialBlockDownload() const
20172017
{
2018-
// Optimization: pre-test latch before taking the lock.
2019-
if (m_cached_finished_ibd.load(std::memory_order_relaxed))
2020-
return false;
2021-
2022-
LOCK(cs_main);
20232018
if (m_cached_finished_ibd.load(std::memory_order_relaxed))
20242019
return false;
20252020
if (m_blockman.LoadingBlocks()) {
20262021
return true;
20272022
}
2028-
CChain& chain{ActiveChain()};
2029-
if (chain.Tip() == nullptr) {
2030-
return true;
2031-
}
2032-
if (chain.Tip()->nChainWork < MinimumChainWork()) {
2023+
if (!m_cached_chaintip_recent)
20332024
return true;
2034-
}
2035-
if (chain.Tip()->Time() < Now<NodeSeconds>() - m_options.max_tip_age) {
2036-
return true;
2037-
}
20382025
LogInfo("Leaving InitialBlockDownload (latching to false)");
20392026
m_cached_finished_ibd.store(true, std::memory_order_relaxed);
20402027
return false;

0 commit comments

Comments
 (0)