77
88#include < primitives/block.h>
99#include < scheduler.h>
10- #include < txmempool.h>
1110
1211#include < future>
12+ #include < unordered_map>
1313#include < utility>
1414
1515#include < boost/signals2/signal.hpp>
@@ -46,11 +46,6 @@ struct MainSignalsInstance {
4646
4747static CMainSignals g_signals;
4848
49- // This map has to a separate global instead of a member of MainSignalsInstance,
50- // because RegisterWithMempoolSignals is currently called before RegisterBackgroundSignalScheduler,
51- // so MainSignalsInstance hasn't been created yet.
52- static std::unordered_map<CTxMemPool*, boost::signals2::scoped_connection> g_connNotifyEntryRemoved;
53-
5449void CMainSignals::RegisterBackgroundSignalScheduler (CScheduler& scheduler) {
5550 assert (!m_internals);
5651 m_internals.reset (new MainSignalsInstance (&scheduler));
@@ -71,17 +66,6 @@ size_t CMainSignals::CallbacksPending() {
7166 return m_internals->m_schedulerClient .CallbacksPending ();
7267}
7368
74- void CMainSignals::RegisterWithMempoolSignals (CTxMemPool& pool) {
75- g_connNotifyEntryRemoved.emplace (std::piecewise_construct,
76- std::forward_as_tuple (&pool),
77- std::forward_as_tuple (pool.NotifyEntryRemoved .connect (std::bind (&CMainSignals::MempoolEntryRemoved, this , std::placeholders::_1, std::placeholders::_2)))
78- );
79- }
80-
81- void CMainSignals::UnregisterWithMempoolSignals (CTxMemPool& pool) {
82- g_connNotifyEntryRemoved.erase (&pool);
83- }
84-
8569CMainSignals& GetMainSignals ()
8670{
8771 return g_signals;
@@ -126,13 +110,6 @@ void SyncWithValidationInterfaceQueue() {
126110 promise.get_future ().wait ();
127111}
128112
129- void CMainSignals::MempoolEntryRemoved (CTransactionRef ptx, MemPoolRemovalReason reason) {
130- if (reason != MemPoolRemovalReason::BLOCK && reason != MemPoolRemovalReason::CONFLICT) {
131- m_internals->m_schedulerClient .AddToProcessQueue ([ptx, this ] {
132- m_internals->TransactionRemovedFromMempool (ptx);
133- });
134- }
135- }
136113
137114void CMainSignals::UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload ) {
138115 // Dependencies exist that require UpdatedBlockTip events to be delivered in the order in which
@@ -150,6 +127,12 @@ void CMainSignals::TransactionAddedToMempool(const CTransactionRef &ptx) {
150127 });
151128}
152129
130+ void CMainSignals::TransactionRemovedFromMempool (const CTransactionRef &ptx) {
131+ m_internals->m_schedulerClient .AddToProcessQueue ([ptx, this ] {
132+ m_internals->TransactionRemovedFromMempool (ptx);
133+ });
134+ }
135+
153136void CMainSignals::BlockConnected (const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex, const std::shared_ptr<const std::vector<CTransactionRef>>& pvtxConflicted) {
154137 m_internals->m_schedulerClient .AddToProcessQueue ([pblock, pindex, pvtxConflicted, this ] {
155138 m_internals->BlockConnected (pblock, pindex, *pvtxConflicted);
0 commit comments