Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.cpp
Show First 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | public: | ||||
~RpcHandlerImpl() override { disconnect(); } | ~RpcHandlerImpl() override { disconnect(); } | ||||
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) : m_node(node) {} | explicit ChainImpl(NodeContext &node, const CChainParams ¶ms) | ||||
: m_node(node), m_params(params) {} | |||||
std::unique_ptr<Chain::Lock> lock(bool try_lock) override { | std::unique_ptr<Chain::Lock> lock(bool try_lock) override { | ||||
auto lock = std::make_unique<LockImpl>( | auto lock = std::make_unique<LockImpl>( | ||||
::cs_main, "cs_main", __FILE__, __LINE__, try_lock); | ::cs_main, "cs_main", __FILE__, __LINE__, try_lock); | ||||
if (try_lock && lock && !*lock) { | if (try_lock && lock && !*lock) { | ||||
return {}; | return {}; | ||||
} | } | ||||
// Temporary to avoid CWG 1579 | // Temporary to avoid CWG 1579 | ||||
std::unique_ptr<Chain::Lock> result = std::move(lock); | std::unique_ptr<Chain::Lock> result = std::move(lock); | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | public: | ||||
int rpcSerializationFlags() override { return RPCSerializationFlags(); } | int rpcSerializationFlags() override { return RPCSerializationFlags(); } | ||||
void requestMempoolTransactions(Notifications ¬ifications) override { | void requestMempoolTransactions(Notifications ¬ifications) override { | ||||
LOCK2(::cs_main, ::g_mempool.cs); | LOCK2(::cs_main, ::g_mempool.cs); | ||||
for (const CTxMemPoolEntry &entry : ::g_mempool.mapTx) { | for (const CTxMemPoolEntry &entry : ::g_mempool.mapTx) { | ||||
notifications.TransactionAddedToMempool(entry.GetSharedTx()); | notifications.TransactionAddedToMempool(entry.GetSharedTx()); | ||||
} | } | ||||
} | } | ||||
NodeContext &m_node; | NodeContext &m_node; | ||||
const CChainParams &m_params; | |||||
}; | }; | ||||
} // namespace | } // namespace | ||||
std::unique_ptr<Chain> MakeChain(NodeContext &node) { | std::unique_ptr<Chain> MakeChain(NodeContext &node, | ||||
return std::make_unique<ChainImpl>(node); | const CChainParams ¶ms) { | ||||
return std::make_unique<ChainImpl>(node, params); | |||||
} | } | ||||
} // namespace interfaces | } // namespace interfaces |