mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Cover UTXO set access with lock annotations
i.e. any CoinsViews members. Adds a lock acquisition to `gettxoutsetinfo` RPC to comply with added annotations. Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
This commit is contained in:
@@ -519,14 +519,14 @@ class CoinsViews {
|
||||
public:
|
||||
//! The lowest level of the CoinsViews cache hierarchy sits in a leveldb database on disk.
|
||||
//! All unspent coins reside in this store.
|
||||
CCoinsViewDB m_dbview;
|
||||
CCoinsViewDB m_dbview GUARDED_BY(cs_main);
|
||||
|
||||
//! This view wraps access to the leveldb instance and handles read errors gracefully.
|
||||
CCoinsViewErrorCatcher m_catcherview;
|
||||
CCoinsViewErrorCatcher m_catcherview GUARDED_BY(cs_main);
|
||||
|
||||
//! This is the top layer of the cache hierarchy - it keeps as many coins in memory as
|
||||
//! can fit per the dbcache setting.
|
||||
std::unique_ptr<CCoinsViewCache> m_cacheview;
|
||||
std::unique_ptr<CCoinsViewCache> m_cacheview GUARDED_BY(cs_main);
|
||||
|
||||
//! This constructor initializes CCoinsViewDB and CCoinsViewErrorCatcher instances, but it
|
||||
//! *does not* create a CCoinsViewCache instance by default. This is done separately because the
|
||||
@@ -537,7 +537,7 @@ public:
|
||||
CoinsViews(std::string ldb_name, size_t cache_size_bytes, bool in_memory, bool should_wipe);
|
||||
|
||||
//! Initialize the CCoinsViewCache member.
|
||||
void InitCache();
|
||||
void InitCache() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -609,11 +609,11 @@ public:
|
||||
|
||||
//! Initialize the in-memory coins cache (to be done after the health of the on-disk database
|
||||
//! is verified).
|
||||
void InitCoinsCache();
|
||||
void InitCoinsCache() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
//! @returns whether or not the CoinsViews object has been fully initialized and we can
|
||||
//! safely flush this object to disk.
|
||||
bool CanFlushToDisk() {
|
||||
bool CanFlushToDisk() EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
|
||||
return m_coins_views && m_coins_views->m_cacheview;
|
||||
}
|
||||
|
||||
@@ -629,21 +629,21 @@ public:
|
||||
std::set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexCandidates;
|
||||
|
||||
//! @returns A reference to the in-memory cache of the UTXO set.
|
||||
CCoinsViewCache& CoinsTip()
|
||||
CCoinsViewCache& CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
assert(m_coins_views->m_cacheview);
|
||||
return *m_coins_views->m_cacheview.get();
|
||||
}
|
||||
|
||||
//! @returns A reference to the on-disk UTXO set database.
|
||||
CCoinsViewDB& CoinsDB()
|
||||
CCoinsViewDB& CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
return m_coins_views->m_dbview;
|
||||
}
|
||||
|
||||
//! @returns A reference to a wrapped view of the in-memory UTXO set that
|
||||
//! handles disk read errors gracefully.
|
||||
CCoinsViewErrorCatcher& CoinsErrorCatcher()
|
||||
CCoinsViewErrorCatcher& CoinsErrorCatcher() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
return m_coins_views->m_catcherview;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user