From fa530bcb9c13b58ab1b2068b48aa3fff910e2f87 Mon Sep 17 00:00:00 2001 From: MacroFake Date: Tue, 12 Jul 2022 17:45:49 +0200 Subject: Add ChainstateManager::GetMutex(), an alias for ::cs_main --- src/validation.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/validation.h b/src/validation.h index 17286c7910..856370d5b4 100644 --- a/src/validation.h +++ b/src/validation.h @@ -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. -- cgit v1.2.3