Merge bitcoin/bitcoin#34443: validation: follow-up nits for lock-free IsInitialBlockDownload()
eeb4d28148validation: follow-up nits for lock-free `IsInitialBlockDownload()` (Lőrinc) Pull request description: Innocent follow-up to #34253: * Add `AssertLockHeld(cs_main)` to `ChainstateManager::UpdateIBDStatus()` given it's already annotated with `EXCLUSIVE_LOCKS_REQUIRED(cs_main)`. * Fix outdated comment about constness of `ChainstateManager::IsInitialBlockDownload()` (compilation and build passes without it). * And since we're touching it, we might as well mark `ChainstateManager::IsInitialBlockDownload()` as `noexcept` now. ACKs for top commit: davidgumberg: crACK https://github.com/bitcoin/bitcoin/commit/eeb4d2814803c09af602ca5c9810438dd5e987fb sedited: ACKeeb4d28148mzumsande: utACKeeb4d28148Tree-SHA512: 110cf5b03dc4f4cf6e61563ef69da6368e43009cf0fe1b10870cb4f55203c347444c8623aae7357d0ee5ba3f4b10da535b440a5871c9c5a4f7f8f88c2accd1f1
This commit is contained in:
2 files changed
+4
-8
No files matched your search
+3
-7
@@ -1935,13 +1935,8 @@ void Chainstate::InitCoinsCache(size_t cache_size_bytes)
|
|||||||
m_coins_views->InitCache();
|
m_coins_views->InitCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function must be marked `const` so that `CValidationInterface` clients
|
// Lock-free: depends on `m_cached_is_ibd`, which is latched by `UpdateIBDStatus()`.
|
||||||
// (which are given a `const Chainstate*`) can call it.
|
bool ChainstateManager::IsInitialBlockDownload() const noexcept
|
||||||
//
|
|
||||||
// It is lock-free and depends on `m_cached_is_ibd`, which is latched by
|
|
||||||
// `UpdateIBDStatus()`.
|
|
||||||
//
|
|
||||||
bool ChainstateManager::IsInitialBlockDownload() const
|
|
||||||
{
|
{
|
||||||
return m_cached_is_ibd.load(std::memory_order_relaxed);
|
return m_cached_is_ibd.load(std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
@@ -3324,6 +3319,7 @@ static SynchronizationState GetSynchronizationState(bool init, bool blockfiles_i
|
|||||||
|
|
||||||
void ChainstateManager::UpdateIBDStatus()
|
void ChainstateManager::UpdateIBDStatus()
|
||||||
{
|
{
|
||||||
|
AssertLockHeld(cs_main);
|
||||||
if (!m_cached_is_ibd.load(std::memory_order_relaxed)) return;
|
if (!m_cached_is_ibd.load(std::memory_order_relaxed)) return;
|
||||||
if (m_blockman.LoadingBlocks()) return;
|
if (m_blockman.LoadingBlocks()) return;
|
||||||
if (!CurrentChainstate().m_chain.IsTipRecent(MinimumChainWork(), m_options.max_tip_age)) return;
|
if (!CurrentChainstate().m_chain.IsTipRecent(MinimumChainWork(), m_options.max_tip_age)) return;
|
||||||
|
|||||||
+1
-1
@@ -1187,7 +1187,7 @@ public:
|
|||||||
mutable VersionBitsCache m_versionbitscache;
|
mutable VersionBitsCache m_versionbitscache;
|
||||||
|
|
||||||
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
||||||
bool IsInitialBlockDownload() const;
|
bool IsInitialBlockDownload() const noexcept;
|
||||||
|
|
||||||
/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
|
/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
|
||||||
double GuessVerificationProgress(const CBlockIndex* pindex) const EXCLUSIVE_LOCKS_REQUIRED(GetMutex());
|
double GuessVerificationProgress(const CBlockIndex* pindex) const EXCLUSIVE_LOCKS_REQUIRED(GetMutex());
|
||||||
|
|||||||
Reference in new issue
Block a user