mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
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
This commit is contained in:
@@ -4,13 +4,37 @@
|
||||
|
||||
#include <interfaces/chain.h>
|
||||
|
||||
#include <sync.h>
|
||||
#include <util/system.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace interfaces {
|
||||
namespace {
|
||||
|
||||
class LockImpl : public Chain::Lock
|
||||
{
|
||||
};
|
||||
|
||||
class LockingStateImpl : public LockImpl, public UniqueLock<CCriticalSection>
|
||||
{
|
||||
using UniqueLock::UniqueLock;
|
||||
};
|
||||
|
||||
class ChainImpl : public Chain
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<Chain::Lock> lock(bool try_lock) override
|
||||
{
|
||||
auto result = MakeUnique<LockingStateImpl>(::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<Chain::Lock> assumeLocked() override { return MakeUnique<LockImpl>(); }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user