9
9
#include " primitives/block.h"
10
10
#include " scheduler.h"
11
11
#include " sync.h"
12
+ #include " txmempool.h"
12
13
#include " util.h"
13
14
14
15
#include < list>
@@ -21,6 +22,7 @@ struct MainSignalsInstance {
21
22
boost::signals2::signal<void (const CTransactionRef &)> TransactionAddedToMempool;
22
23
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::vector<CTransactionRef>&)> BlockConnected;
23
24
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &)> BlockDisconnected;
25
+ boost::signals2::signal<void (const CTransactionRef &)> TransactionRemovedFromMempool;
24
26
boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
25
27
boost::signals2::signal<void (const uint256 &)> Inventory;
26
28
boost::signals2::signal<void (int64_t nBestBlockTime, CConnman* connman)> Broadcast;
@@ -50,6 +52,14 @@ void CMainSignals::FlushBackgroundCallbacks() {
50
52
m_internals->m_schedulerClient .EmptyQueue ();
51
53
}
52
54
55
+ void CMainSignals::RegisterWithMempoolSignals (CTxMemPool& pool) {
56
+ pool.NotifyEntryRemoved .connect (boost::bind (&CMainSignals::MempoolEntryRemoved, this , _1, _2));
57
+ }
58
+
59
+ void CMainSignals::UnregisterWithMempoolSignals (CTxMemPool& pool) {
60
+ pool.NotifyEntryRemoved .disconnect (boost::bind (&CMainSignals::MempoolEntryRemoved, this , _1, _2));
61
+ }
62
+
53
63
CMainSignals& GetMainSignals ()
54
64
{
55
65
return g_signals;
@@ -60,6 +70,7 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
60
70
g_signals.m_internals ->TransactionAddedToMempool .connect (boost::bind (&CValidationInterface::TransactionAddedToMempool, pwalletIn, _1));
61
71
g_signals.m_internals ->BlockConnected .connect (boost::bind (&CValidationInterface::BlockConnected, pwalletIn, _1, _2, _3));
62
72
g_signals.m_internals ->BlockDisconnected .connect (boost::bind (&CValidationInterface::BlockDisconnected, pwalletIn, _1));
73
+ g_signals.m_internals ->TransactionRemovedFromMempool .connect (boost::bind (&CValidationInterface::TransactionRemovedFromMempool, pwalletIn, _1));
63
74
g_signals.m_internals ->SetBestChain .connect (boost::bind (&CValidationInterface::SetBestChain, pwalletIn, _1));
64
75
g_signals.m_internals ->Inventory .connect (boost::bind (&CValidationInterface::Inventory, pwalletIn, _1));
65
76
g_signals.m_internals ->Broadcast .connect (boost::bind (&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2));
@@ -75,6 +86,7 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
75
86
g_signals.m_internals ->TransactionAddedToMempool .disconnect (boost::bind (&CValidationInterface::TransactionAddedToMempool, pwalletIn, _1));
76
87
g_signals.m_internals ->BlockConnected .disconnect (boost::bind (&CValidationInterface::BlockConnected, pwalletIn, _1, _2, _3));
77
88
g_signals.m_internals ->BlockDisconnected .disconnect (boost::bind (&CValidationInterface::BlockDisconnected, pwalletIn, _1));
89
+ g_signals.m_internals ->TransactionRemovedFromMempool .disconnect (boost::bind (&CValidationInterface::TransactionRemovedFromMempool, pwalletIn, _1));
78
90
g_signals.m_internals ->UpdatedBlockTip .disconnect (boost::bind (&CValidationInterface::UpdatedBlockTip, pwalletIn, _1, _2, _3));
79
91
g_signals.m_internals ->NewPoWValidBlock .disconnect (boost::bind (&CValidationInterface::NewPoWValidBlock, pwalletIn, _1, _2));
80
92
}
@@ -87,10 +99,17 @@ void UnregisterAllValidationInterfaces() {
87
99
g_signals.m_internals ->TransactionAddedToMempool .disconnect_all_slots ();
88
100
g_signals.m_internals ->BlockConnected .disconnect_all_slots ();
89
101
g_signals.m_internals ->BlockDisconnected .disconnect_all_slots ();
102
+ g_signals.m_internals ->TransactionRemovedFromMempool .disconnect_all_slots ();
90
103
g_signals.m_internals ->UpdatedBlockTip .disconnect_all_slots ();
91
104
g_signals.m_internals ->NewPoWValidBlock .disconnect_all_slots ();
92
105
}
93
106
107
+ void CMainSignals::MempoolEntryRemoved (CTransactionRef ptx, MemPoolRemovalReason reason) {
108
+ if (reason != MemPoolRemovalReason::BLOCK && reason != MemPoolRemovalReason::CONFLICT) {
109
+ m_internals->TransactionRemovedFromMempool (ptx);
110
+ }
111
+ }
112
+
94
113
void CMainSignals::UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload ) {
95
114
m_internals->UpdatedBlockTip (pindexNew, pindexFork, fInitialDownload );
96
115
}
0 commit comments