aboutsummaryrefslogtreecommitdiff
path: root/src/validation.h
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-07-12 17:45:49 +0200
committerMacroFake <falke.marco@gmail.com>2022-08-16 17:25:19 +0200
commitfa530bcb9c13b58ab1b2068b48aa3fff910e2f87 (patch)
tree8c3ca8e8c160a25a0dd7d5bdbbf6bba3afaf46b7 /src/validation.h
parent0f90b586863f68aa01e089e48a06802405e2b83b (diff)
downloadbitcoin-fa530bcb9c13b58ab1b2068b48aa3fff910e2f87.tar.xz
Add ChainstateManager::GetMutex(), an alias for ::cs_main
Diffstat (limited to 'src/validation.h')
-rw-r--r--src/validation.h13
1 files changed, 13 insertions, 0 deletions
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.