From 79d579f4e11b57f90fed314bccd25230f918729f Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Wed, 26 Jul 2017 10:23:01 -0400 Subject: Remove uses of cs_main in wallet code This commit does not change behavior. It is easiest to review this change with: git log -p -n1 -U0 --- src/interfaces/chain.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/interfaces/chain.cpp') diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index 28b36717d..2571a9103 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -4,13 +4,37 @@ #include +#include #include +#include + +#include +#include namespace interfaces { namespace { +class LockImpl : public Chain::Lock +{ +}; + +class LockingStateImpl : public LockImpl, public UniqueLock +{ + using UniqueLock::UniqueLock; +}; + class ChainImpl : public Chain { +public: + std::unique_ptr lock(bool try_lock) override + { + auto result = MakeUnique(::cs_main, "cs_main", __FILE__, __LINE__, try_lock); + if (try_lock && result && !*result) return {}; + // std::move necessary on some compilers due to conversion from + // LockingStateImpl to Lock pointer + return std::move(result); + } + std::unique_ptr assumeLocked() override { return MakeUnique(); } }; } // namespace -- cgit v1.2.3