Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | bool FillBlock(const CBlockIndex *index, const FoundBlock &block, | ||||
if (!ReadBlockFromDisk(*block.m_data, index, | if (!ReadBlockFromDisk(*block.m_data, index, | ||||
Params().GetConsensus())) { | Params().GetConsensus())) { | ||||
block.m_data->SetNull(); | block.m_data->SetNull(); | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
class LockImpl : public Chain::Lock, public UniqueLock<RecursiveMutex> { | |||||
using UniqueLock::UniqueLock; | |||||
}; // namespace interfaces | |||||
class NotificationsProxy : public CValidationInterface { | class NotificationsProxy : public CValidationInterface { | ||||
public: | public: | ||||
explicit NotificationsProxy( | explicit NotificationsProxy( | ||||
std::shared_ptr<Chain::Notifications> notifications) | std::shared_ptr<Chain::Notifications> notifications) | ||||
: m_notifications(std::move(notifications)) {} | : m_notifications(std::move(notifications)) {} | ||||
virtual ~NotificationsProxy() = default; | virtual ~NotificationsProxy() = default; | ||||
void TransactionAddedToMempool(const CTransactionRef &tx) override { | void TransactionAddedToMempool(const CTransactionRef &tx) override { | ||||
m_notifications->TransactionAddedToMempool(tx); | m_notifications->TransactionAddedToMempool(tx); | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | public: | ||||
CRPCCommand m_command; | CRPCCommand m_command; | ||||
const CRPCCommand *m_wrapped_command; | const CRPCCommand *m_wrapped_command; | ||||
}; | }; | ||||
class ChainImpl : public Chain { | class ChainImpl : public Chain { | ||||
public: | public: | ||||
explicit ChainImpl(NodeContext &node, const CChainParams ¶ms) | explicit ChainImpl(NodeContext &node, const CChainParams ¶ms) | ||||
: m_node(node), m_params(params) {} | : m_node(node), m_params(params) {} | ||||
std::unique_ptr<Chain::Lock> lock(bool try_lock) override { | |||||
auto lock = std::make_unique<LockImpl>( | |||||
::cs_main, "cs_main", __FILE__, __LINE__, try_lock); | |||||
if (try_lock && lock && !*lock) { | |||||
return {}; | |||||
} | |||||
// Temporary to avoid CWG 1579 | |||||
std::unique_ptr<Chain::Lock> result = std::move(lock); | |||||
return result; | |||||
} | |||||
Optional<int> getHeight() override { | Optional<int> getHeight() override { | ||||
LOCK(::cs_main); | LOCK(::cs_main); | ||||
int height = ::ChainActive().Height(); | int height = ::ChainActive().Height(); | ||||
if (height >= 0) { | if (height >= 0) { | ||||
return height; | return height; | ||||
} | } | ||||
return nullopt; | return nullopt; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 277 Lines • Show Last 20 Lines |