mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Remove temporary method assumeLocked(). Remove LockingStateImpl. Remove redundant cs_main locks.
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
namespace interfaces {
|
||||
namespace {
|
||||
|
||||
class LockImpl : public Chain::Lock
|
||||
class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
|
||||
{
|
||||
Optional<int> getHeight() override
|
||||
{
|
||||
@@ -155,10 +155,7 @@ class LockImpl : public Chain::Lock
|
||||
return AcceptToMemoryPool(::mempool, state, tx, nullptr /* missing inputs */, nullptr /* txn replaced */,
|
||||
false /* bypass limits */, absurd_fee);
|
||||
}
|
||||
};
|
||||
|
||||
class LockingStateImpl : public LockImpl, public UniqueLock<CCriticalSection>
|
||||
{
|
||||
using UniqueLock::UniqueLock;
|
||||
};
|
||||
|
||||
@@ -249,13 +246,12 @@ 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);
|
||||
auto result = MakeUnique<LockImpl>(::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
|
||||
// LockImpl to Lock pointer
|
||||
return std::move(result);
|
||||
}
|
||||
std::unique_ptr<Chain::Lock> assumeLocked() override { return MakeUnique<LockImpl>(); }
|
||||
bool findBlock(const uint256& hash, CBlock* block, int64_t* time, int64_t* time_max) override
|
||||
{
|
||||
CBlockIndex* index;
|
||||
|
||||
@@ -138,11 +138,6 @@ public:
|
||||
//! unlocked when the returned interface is freed.
|
||||
virtual std::unique_ptr<Lock> lock(bool try_lock = false) = 0;
|
||||
|
||||
//! Return Lock interface assuming chain is already locked. This
|
||||
//! method is temporary and is only used in a few places to avoid changing
|
||||
//! behavior while code is transitioned to use the Chain::Lock interface.
|
||||
virtual std::unique_ptr<Lock> assumeLocked() = 0;
|
||||
|
||||
//! Return whether node has the block and optionally return block metadata
|
||||
//! or contents.
|
||||
//!
|
||||
|
||||
Reference in New Issue
Block a user