Add missing thread safety lock assertions in validation.h

This commit is contained in:
Jon Atack 2022-01-27 12:37:50 +01:00
parent 37af8a20cf
commit f485a07454
No known key found for this signature in database
GPG Key ID: 796C4109063D4EAF

View File

@ -529,7 +529,9 @@ public:
//! @returns whether or not the CoinsViews object has been fully initialized and we can //! @returns whether or not the CoinsViews object has been fully initialized and we can
//! safely flush this object to disk. //! safely flush this object to disk.
bool CanFlushToDisk() const EXCLUSIVE_LOCKS_REQUIRED(cs_main) { bool CanFlushToDisk() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
{
AssertLockHeld(::cs_main);
return m_coins_views && m_coins_views->m_cacheview; return m_coins_views && m_coins_views->m_cacheview;
} }
@ -557,15 +559,17 @@ public:
std::set<CBlockIndex*, node::CBlockIndexWorkComparator> setBlockIndexCandidates; std::set<CBlockIndex*, node::CBlockIndexWorkComparator> setBlockIndexCandidates;
//! @returns A reference to the in-memory cache of the UTXO set. //! @returns A reference to the in-memory cache of the UTXO set.
CCoinsViewCache& CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main) CCoinsViewCache& CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
{ {
AssertLockHeld(::cs_main);
assert(m_coins_views->m_cacheview); assert(m_coins_views->m_cacheview);
return *m_coins_views->m_cacheview.get(); return *m_coins_views->m_cacheview.get();
} }
//! @returns A reference to the on-disk UTXO set database. //! @returns A reference to the on-disk UTXO set database.
CCoinsViewDB& CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(cs_main) CCoinsViewDB& CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
{ {
AssertLockHeld(::cs_main);
return m_coins_views->m_dbview; return m_coins_views->m_dbview;
} }
@ -577,8 +581,9 @@ public:
//! @returns A reference to a wrapped view of the in-memory UTXO set that //! @returns A reference to a wrapped view of the in-memory UTXO set that
//! handles disk read errors gracefully. //! handles disk read errors gracefully.
CCoinsViewErrorCatcher& CoinsErrorCatcher() EXCLUSIVE_LOCKS_REQUIRED(cs_main) CCoinsViewErrorCatcher& CoinsErrorCatcher() EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
{ {
AssertLockHeld(::cs_main);
return m_coins_views->m_catcherview; return m_coins_views->m_catcherview;
} }
@ -924,6 +929,7 @@ public:
node::BlockMap& BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) node::BlockMap& BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
{ {
AssertLockHeld(::cs_main);
return m_blockman.m_block_index; return m_blockman.m_block_index;
} }