Add ChainstateManager::GetMutex(), an alias for ::cs_main

This commit is contained in:
MacroFake 2022-07-12 17:45:49 +02:00
parent 0f90b58686
commit fa530bcb9c
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -868,6 +868,19 @@ public:
const CChainParams& GetParams() const { return m_chainparams; }
const Consensus::Params& GetConsensus() const { return m_chainparams.GetConsensus(); }
/**
* Alias for ::cs_main.
* Should be used in new code to make it easier to make ::cs_main a member
* of this class.
* Generally, methods of this class should be annotated to require this
* mutex. This will make calling code more verbose, but also help to:
* - Clarify that the method will acquire a mutex that heavily affects
* overall performance.
* - Force call sites to think how long they need to acquire the mutex to
* get consistent results.
*/
RecursiveMutex& GetMutex() const LOCK_RETURNED(::cs_main) { return ::cs_main; }
std::thread m_load_block;
//! A single BlockManager instance is shared across each constructed
//! chainstate to avoid duplicating block metadata.