aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2024-01-24 10:28:55 +0100
committerTheCharlatan <seb.kung@gmail.com>2024-02-15 13:28:45 +0100
commit3fba3d5deec6d7bae33823b8da7682f9b03d9deb (patch)
treeda08b52bcd7612ee35a09335c2fec89d8795786a /src/txmempool.cpp
parent7143d4388407ab3d12005e55a02d5e8f334e4dc9 (diff)
downloadbitcoin-3fba3d5deec6d7bae33823b8da7682f9b03d9deb.tar.xz
[refactor] Make signals optional in mempool and chainman
This is done in preparation for the next two commits, where the CMainSignals are de-globalized. This avoids adding new constructor arguments to the ChainstateManager and CTxMemPool classes over the next two commits. This could also allow future tests that are only interested in the internal behaviour of the classes to forgo instantiating the signals.
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index de340f6b6d..0bee27c2b2 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -406,7 +406,8 @@ CTxMemPool::CTxMemPool(const Options& opts)
m_require_standard{opts.require_standard},
m_full_rbf{opts.full_rbf},
m_persist_v1_dat{opts.persist_v1_dat},
- m_limits{opts.limits}
+ m_limits{opts.limits},
+ m_signals{opts.signals}
{
}
@@ -487,12 +488,12 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
// even if not directly reported below.
uint64_t mempool_sequence = GetAndIncrementSequence();
- if (reason != MemPoolRemovalReason::BLOCK) {
+ if (reason != MemPoolRemovalReason::BLOCK && m_signals) {
// Notify clients that a transaction has been removed from the mempool
// for any reason except being included in a block. Clients interested
// in transactions included in blocks can subscribe to the BlockConnected
// notification.
- GetMainSignals().TransactionRemovedFromMempool(it->GetSharedTx(), reason, mempool_sequence);
+ m_signals->TransactionRemovedFromMempool(it->GetSharedTx(), reason, mempool_sequence);
}
TRACE5(mempool, removed,
it->GetTx().GetHash().data(),
@@ -643,7 +644,9 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
removeConflicts(*tx);
ClearPrioritisation(tx->GetHash());
}
- GetMainSignals().MempoolTransactionsRemovedForBlock(txs_removed_for_block, nBlockHeight);
+ if (m_signals) {
+ m_signals->MempoolTransactionsRemovedForBlock(txs_removed_for_block, nBlockHeight);
+ }
lastRollingFeeUpdate = GetTime();
blockSinceLastRollingFeeBump = true;
}