Skip to content

Commit

Permalink
Add ChainstateManager::GetMutex(), an alias for ::cs_main
Browse files Browse the repository at this point in the history
  • Loading branch information
MacroFake committed Aug 16, 2022
1 parent 0f90b58 commit fa530bc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,19 @@ class ChainstateManager
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.
Expand Down

0 comments on commit fa530bc

Please sign in to comment.