Bitcoin ABC 0.31.6
P2P Digital Currency
txmempool.cpp
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#include <txmempool.h>
7
8#include <clientversion.h>
9#include <coins.h>
10#include <common/system.h>
11#include <config.h>
12#include <consensus/consensus.h>
13#include <consensus/tx_verify.h>
15#include <logging.h>
16#include <policy/fees.h>
17#include <policy/policy.h>
18#include <reverse_iterator.h>
19#include <undo.h>
20#include <util/check.h>
21#include <util/moneystr.h>
22#include <util/time.h>
23#include <validationinterface.h>
24#include <version.h>
25
26#include <algorithm>
27#include <cmath>
28#include <limits>
29#include <vector>
30
32 setEntries &setAncestors,
33 CTxMemPoolEntry::Parents &staged_ancestors) const {
34 while (!staged_ancestors.empty()) {
35 const auto stage = staged_ancestors.begin()->get();
36
37 txiter stageit = mapTx.find(stage->GetTx().GetId());
38 assert(stageit != mapTx.end());
39 setAncestors.insert(stageit);
40 staged_ancestors.erase(staged_ancestors.begin());
41
42 const CTxMemPoolEntry::Parents &parents =
43 (*stageit)->GetMemPoolParentsConst();
44 for (const auto &parent : parents) {
45 txiter parent_it = mapTx.find(parent.get()->GetTx().GetId());
46 assert(parent_it != mapTx.end());
47
48 // If this is a new ancestor, add it.
49 if (setAncestors.count(parent_it) == 0) {
50 staged_ancestors.insert(parent);
51 }
52 }
53 }
54
55 return true;
56}
57
59 const CTxMemPoolEntryRef &entry, setEntries &setAncestors,
60 bool fSearchForParents /* = true */) const {
61 CTxMemPoolEntry::Parents staged_ancestors;
62 const CTransaction &tx = entry->GetTx();
63
64 if (fSearchForParents) {
65 // Get parents of this transaction that are in the mempool
66 // GetMemPoolParents() is only valid for entries in the mempool, so we
67 // iterate mapTx to find parents.
68 for (const CTxIn &in : tx.vin) {
69 std::optional<txiter> piter = GetIter(in.prevout.GetTxId());
70 if (!piter) {
71 continue;
72 }
73 staged_ancestors.insert(**piter);
74 }
75 } else {
76 // If we're not searching for parents, we require this to be an entry in
77 // the mempool already.
78 staged_ancestors = entry->GetMemPoolParentsConst();
79 }
80
81 return CalculateAncestors(setAncestors, staged_ancestors);
82}
83
85 // add or remove this tx as a child of each parent
86 for (const auto &parent : (*it)->GetMemPoolParentsConst()) {
87 auto parent_it = mapTx.find(parent.get()->GetTx().GetId());
88 assert(parent_it != mapTx.end());
89 UpdateChild(parent_it, it, add);
90 }
91}
92
94 const CTxMemPoolEntry::Children &children =
95 (*it)->GetMemPoolChildrenConst();
96 for (const auto &child : children) {
97 auto updateIt = mapTx.find(child.get()->GetTx().GetId());
98 assert(updateIt != mapTx.end());
99 UpdateParent(updateIt, it, false);
100 }
101}
102
104 for (txiter removeIt : entriesToRemove) {
105 // Note that UpdateParentsOf severs the child links that point to
106 // removeIt in the entries for the parents of removeIt.
107 UpdateParentsOf(false, removeIt);
108 }
109
110 // After updating all the parent links, we can now sever the link between
111 // each transaction being removed and any mempool children (ie, update
112 // CTxMemPoolEntry::m_parents for each direct child of a transaction being
113 // removed).
114 for (txiter removeIt : entriesToRemove) {
115 UpdateChildrenForRemoval(removeIt);
116 }
117}
118
119CTxMemPool::CTxMemPool(const Config &config, const Options &opts)
120 : m_check_ratio(opts.check_ratio),
121 m_finalizedTxsFitter(node::BlockFitter(config)),
122 m_orphanage(std::make_unique<TxOrphanage>()),
123 m_conflicting(std::make_unique<TxConflicting>()),
124 m_max_size_bytes{opts.max_size_bytes}, m_expiry{opts.expiry},
125 m_min_relay_feerate{opts.min_relay_feerate},
126 m_dust_relay_feerate{opts.dust_relay_feerate},
127 m_permit_bare_multisig{opts.permit_bare_multisig},
128 m_max_datacarrier_bytes{opts.max_datacarrier_bytes},
129 m_require_standard{opts.require_standard} {
130 // lock free clear
131 _clear();
132}
133
135
136bool CTxMemPool::isSpent(const COutPoint &outpoint) const {
137 LOCK(cs);
138 return mapNextTx.count(outpoint);
139}
140
143}
144
147}
148
150 // get a guaranteed unique id (in case tests re-use the same object)
151 entry->SetEntryId(nextEntryId++);
152
153 // Update transaction for any feeDelta created by PrioritiseTransaction
154 {
155 Amount feeDelta = Amount::zero();
156 ApplyDelta(entry->GetTx().GetId(), feeDelta);
157 entry->UpdateFeeDelta(feeDelta);
158 }
159
160 // Add to memory pool without checking anything.
161 // Used by AcceptToMemoryPool(), which DOES do all the appropriate checks.
162 auto [newit, inserted] = mapTx.insert(entry);
163 // Sanity check: It is a programming error if insertion fails (uniqueness
164 // invariants in mapTx are violated, etc)
165 assert(inserted);
166 // Sanity check: We should always end up inserting at the end of the
167 // entry_id index
168 assert(&*mapTx.get<entry_id>().rbegin() == &*newit);
169
170 // Update cachedInnerUsage to include contained transaction's usage.
171 // (When we update the entry for in-mempool parents, memory usage will be
172 // further updated.)
173 cachedInnerUsage += entry->DynamicMemoryUsage();
174
175 const CTransactionRef tx = entry->GetSharedTx();
176 std::set<TxId> setParentTransactions;
177 for (const CTxIn &in : tx->vin) {
178 mapNextTx.insert(std::make_pair(&in.prevout, tx));
179 setParentTransactions.insert(in.prevout.GetTxId());
180 }
181 // Don't bother worrying about child transactions of this one. It is
182 // guaranteed that a new transaction arriving will not have any children,
183 // because such children would be orphans.
184
185 // Update ancestors with information about this tx
186 for (const auto &pit : GetIterSet(setParentTransactions)) {
187 UpdateParent(newit, pit, true);
188 }
189
190 UpdateParentsOf(true, newit);
191
193 totalTxSize += entry->GetTxSize();
194 m_total_fee += entry->GetFee();
195}
196
198 // We increment mempool sequence value no matter removal reason
199 // even if not directly reported below.
200 uint64_t mempool_sequence = GetAndIncrementSequence();
201
202 const TxId &txid = (*it)->GetTx().GetId();
203
204 if (reason != MemPoolRemovalReason::BLOCK) {
205 // Notify clients that a transaction has been removed from the mempool
206 // for any reason except being included in a block. Clients interested
207 // in transactions included in blocks can subscribe to the
208 // BlockConnected notification.
210 (*it)->GetSharedTx(), reason, mempool_sequence);
211
212 if (auto removed_tx = finalizedTxs.remove(txid)) {
213 m_finalizedTxsFitter.removeTxUnchecked(removed_tx->GetTxSize(),
214 removed_tx->GetSigChecks(),
215 removed_tx->GetFee());
216 }
217 }
218
219 for (const CTxIn &txin : (*it)->GetTx().vin) {
220 mapNextTx.erase(txin.prevout);
221 }
222
223 /* add logging because unchecked */
224 RemoveUnbroadcastTx(txid, true);
225
226 totalTxSize -= (*it)->GetTxSize();
227 m_total_fee -= (*it)->GetFee();
228 cachedInnerUsage -= (*it)->DynamicMemoryUsage();
229 cachedInnerUsage -=
230 memusage::DynamicUsage((*it)->GetMemPoolParentsConst()) +
231 memusage::DynamicUsage((*it)->GetMemPoolChildrenConst());
232 mapTx.erase(it);
234}
235
236// Calculates descendants of entry that are not already in setDescendants, and
237// adds to setDescendants. Assumes entryit is already a tx in the mempool and
238// CTxMemPoolEntry::m_children is correct for tx and all descendants. Also
239// assumes that if an entry is in setDescendants already, then all in-mempool
240// descendants of it are already in setDescendants as well, so that we can save
241// time by not iterating over those entries.
243 setEntries &setDescendants) const {
244 setEntries stage;
245 if (setDescendants.count(entryit) == 0) {
246 stage.insert(entryit);
247 }
248 // Traverse down the children of entry, only adding children that are not
249 // accounted for in setDescendants already (because those children have
250 // either already been walked, or will be walked in this iteration).
251 while (!stage.empty()) {
252 txiter it = *stage.begin();
253 setDescendants.insert(it);
254 stage.erase(stage.begin());
255
256 const CTxMemPoolEntry::Children &children =
257 (*it)->GetMemPoolChildrenConst();
258 for (const auto &child : children) {
259 txiter childiter = mapTx.find(child.get()->GetTx().GetId());
260 assert(childiter != mapTx.end());
261
262 if (!setDescendants.count(childiter)) {
263 stage.insert(childiter);
264 }
265 }
266 }
267}
268
269void CTxMemPool::removeRecursive(const CTransaction &origTx,
270 MemPoolRemovalReason reason) {
271 // Remove transaction from memory pool.
273 setEntries txToRemove;
274 txiter origit = mapTx.find(origTx.GetId());
275 if (origit != mapTx.end()) {
276 txToRemove.insert(origit);
277 } else {
278 // When recursively removing but origTx isn't in the mempool be sure to
279 // remove any children that are in the pool. This can happen during
280 // chain re-orgs if origTx isn't re-accepted into the mempool for any
281 // reason.
282 auto it = mapNextTx.lower_bound(COutPoint(origTx.GetId(), 0));
283 while (it != mapNextTx.end() &&
284 it->first->GetTxId() == origTx.GetId()) {
285 txiter nextit = mapTx.find(it->second->GetId());
286 assert(nextit != mapTx.end());
287 txToRemove.insert(nextit);
288 ++it;
289 }
290 }
291
292 setEntries setAllRemoves;
293 for (txiter it : txToRemove) {
294 CalculateDescendants(it, setAllRemoves);
295 }
296
297 RemoveStaged(setAllRemoves, reason);
298}
299
300void CTxMemPool::removeConflicts(const CTransaction &tx) {
301 // Remove transactions which depend on inputs of tx, recursively
303 for (const CTxIn &txin : tx.vin) {
304 auto it = mapNextTx.find(txin.prevout);
305 if (it != mapNextTx.end()) {
306 const CTransaction &txConflict = *it->second;
307 if (txConflict != tx) {
308 // We reject blocks that contains a tx conflicting with a
309 // finalized tx, so this should never happen
310 Assume(!isAvalancheFinalized(txConflict.GetId()));
311 ClearPrioritisation(txConflict.GetId());
313 }
314 }
315 }
316}
317
323
324 lastRollingFeeUpdate = GetTime();
325 blockSinceLastRollingFeeBump = true;
326}
327
329 const std::vector<CTransactionRef> &vtx) {
331
332 for (const auto &tx : vtx) {
333 // If the tx has a parent, it will be in the block as well or the block
334 // is invalid. If the tx has a child, it can remain in the tree for the
335 // next block. So we can simply remove the txs from the block with no
336 // further check.
337 if (auto removed_tx = finalizedTxs.remove(tx->GetId())) {
338 m_finalizedTxsFitter.removeTxUnchecked(removed_tx->GetTxSize(),
339 removed_tx->GetSigChecks(),
340 removed_tx->GetFee());
341 }
342 }
343}
344
346 mapTx.clear();
347 mapNextTx.clear();
348 totalTxSize = 0;
349 m_total_fee = Amount::zero();
350 cachedInnerUsage = 0;
351 lastRollingFeeUpdate = GetTime();
352 blockSinceLastRollingFeeBump = false;
353 rollingMinimumFeeRate = 0;
355}
356
358 LOCK(cs);
359 _clear();
360}
361
362void CTxMemPool::check(const CCoinsViewCache &active_coins_tip,
363 int64_t spendheight) const {
364 if (m_check_ratio == 0) {
365 return;
366 }
367
368 if (GetRand(m_check_ratio) >= 1) {
369 return;
370 }
371
373 LOCK(cs);
375 "Checking mempool with %u transactions and %u inputs\n",
376 (unsigned int)mapTx.size(), (unsigned int)mapNextTx.size());
377
378 uint64_t checkTotal = 0;
379 Amount check_total_fee{Amount::zero()};
380 uint64_t innerUsage = 0;
381
382 CCoinsViewCache mempoolDuplicate(
383 const_cast<CCoinsViewCache *>(&active_coins_tip));
384
385 for (const CTxMemPoolEntryRef &entry : mapTx.get<entry_id>()) {
386 checkTotal += entry->GetTxSize();
387 check_total_fee += entry->GetFee();
388 innerUsage += entry->DynamicMemoryUsage();
389 const CTransaction &tx = entry->GetTx();
390 innerUsage += memusage::DynamicUsage(entry->GetMemPoolParentsConst()) +
391 memusage::DynamicUsage(entry->GetMemPoolChildrenConst());
392
393 CTxMemPoolEntry::Parents setParentCheck;
394 for (const CTxIn &txin : tx.vin) {
395 // Check that every mempool transaction's inputs refer to available
396 // coins, or other mempool tx's.
397 txiter parentIt = mapTx.find(txin.prevout.GetTxId());
398 if (parentIt != mapTx.end()) {
399 const CTransaction &parentTx = (*parentIt)->GetTx();
400 assert(parentTx.vout.size() > txin.prevout.GetN() &&
401 !parentTx.vout[txin.prevout.GetN()].IsNull());
402 setParentCheck.insert(*parentIt);
403 // also check that parents have a topological ordering before
404 // their children
405 assert((*parentIt)->GetEntryId() < entry->GetEntryId());
406 }
407 // We are iterating through the mempool entries sorted
408 // topologically.
409 // All parents must have been checked before their children and
410 // their coins added to the mempoolDuplicate coins cache.
411 assert(mempoolDuplicate.HaveCoin(txin.prevout));
412 // Check whether its inputs are marked in mapNextTx.
413 auto prevoutNextIt = mapNextTx.find(txin.prevout);
414 assert(prevoutNextIt != mapNextTx.end());
415 assert(prevoutNextIt->first == &txin.prevout);
416 assert(prevoutNextIt->second.get() == &tx);
417 }
418 auto comp = [](const auto &a, const auto &b) -> bool {
419 return a.get()->GetTx().GetId() == b.get()->GetTx().GetId();
420 };
421 assert(setParentCheck.size() == entry->GetMemPoolParentsConst().size());
422 assert(std::equal(setParentCheck.begin(), setParentCheck.end(),
423 entry->GetMemPoolParentsConst().begin(), comp));
424
425 // Verify ancestor state is correct.
426 setEntries setAncestors;
427 std::string dummy;
428
429 const bool ok = CalculateMemPoolAncestors(entry, setAncestors);
430 assert(ok);
431
432 // all ancestors should have entryId < this tx's entryId
433 for (const auto &ancestor : setAncestors) {
434 assert((*ancestor)->GetEntryId() < entry->GetEntryId());
435 }
436
437 // Check children against mapNextTx
438 CTxMemPoolEntry::Children setChildrenCheck;
439 auto iter = mapNextTx.lower_bound(COutPoint(entry->GetTx().GetId(), 0));
440 for (; iter != mapNextTx.end() &&
441 iter->first->GetTxId() == entry->GetTx().GetId();
442 ++iter) {
443 txiter childIt = mapTx.find(iter->second->GetId());
444 // mapNextTx points to in-mempool transactions
445 assert(childIt != mapTx.end());
446 setChildrenCheck.insert(*childIt);
447 }
448 assert(setChildrenCheck.size() ==
449 entry->GetMemPoolChildrenConst().size());
450 assert(std::equal(setChildrenCheck.begin(), setChildrenCheck.end(),
451 entry->GetMemPoolChildrenConst().begin(), comp));
452
453 // Not used. CheckTxInputs() should always pass
454 TxValidationState dummy_state;
455 Amount txfee{Amount::zero()};
456 assert(!tx.IsCoinBase());
457 assert(Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate,
458 spendheight, txfee));
459 for (const auto &input : tx.vin) {
460 mempoolDuplicate.SpendCoin(input.prevout);
461 }
462 AddCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max());
463 }
464
465 for (auto &[_, nextTx] : mapNextTx) {
466 txiter it = mapTx.find(nextTx->GetId());
467 assert(it != mapTx.end());
468 assert((*it)->GetSharedTx() == nextTx);
469 }
470
471 assert(totalTxSize == checkTotal);
472 assert(m_total_fee == check_total_fee);
473 assert(innerUsage == cachedInnerUsage);
474}
475
477 const TxId &txidb) const {
478 LOCK(cs);
479 auto it1 = mapTx.find(txida);
480 if (it1 == mapTx.end()) {
481 return false;
482 }
483 auto it2 = mapTx.find(txidb);
484 if (it2 == mapTx.end()) {
485 return true;
486 }
487 return (*it1)->GetEntryId() < (*it2)->GetEntryId();
488}
489
490void CTxMemPool::getAllTxIds(std::vector<TxId> &vtxid) const {
491 LOCK(cs);
492
493 vtxid.clear();
494 vtxid.reserve(mapTx.size());
495
496 for (const auto &entry : mapTx.get<entry_id>()) {
497 vtxid.push_back(entry->GetTx().GetId());
498 }
499}
500
501static TxMempoolInfo
502GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
503 return TxMempoolInfo{(*it)->GetSharedTx(), (*it)->GetTime(),
504 (*it)->GetFee(), (*it)->GetTxSize(),
505 (*it)->GetModifiedFee() - (*it)->GetFee()};
506}
507
508std::vector<TxMempoolInfo> CTxMemPool::infoAll() const {
509 LOCK(cs);
510
511 std::vector<TxMempoolInfo> ret;
512 ret.reserve(mapTx.size());
513
514 const auto &index = mapTx.get<entry_id>();
515 for (auto it = index.begin(); it != index.end(); ++it) {
516 ret.push_back(GetInfo(mapTx.project<0>(it)));
517 }
518
519 return ret;
520}
521
523 std::vector<TxId> &finalizedTxIds) {
525
526 auto it = mapTx.find(tx->GetTx().GetId());
527 if (it == mapTx.end()) {
528 // Trying to finalize a tx that is not in the mempool !
529 return false;
530 }
531
532 setEntries setAncestors;
533 setAncestors.insert(it);
534 if (!CalculateMemPoolAncestors(tx, setAncestors,
535 /*fSearchForParents=*/false)) {
536 // Failed to get a list of parents for this tx. If we finalize it we
537 // might be missing a parent and generate an invalid block.
538 return false;
539 }
540
541 // Make sure the tx chain would fit the block before adding them.
542 uint64_t sumOfTxSize{0};
543 uint64_t sumOfTxSigChecks{0};
544 for (auto iter_it = setAncestors.begin(); iter_it != setAncestors.end();) {
545 // iter_it is an iterator of mapTx iterator (aka txiter)
546 CTxMemPoolEntryRef entry = **iter_it;
547
548 if (m_finalizedTxsFitter.isBelowBlockMinFeeRate(
549 entry->GetModifiedFeeRate())) {
551 "Delay storing finalized tx %s due to fee rate below the "
552 "block mininmum%s (see -blockmintxfee)\n",
553 tx->GetTx().GetId().ToString(),
554 entry->GetSharedTx()->GetId() == tx->GetSharedTx()->GetId()
555 ? ""
556 : strprintf(" for parent %s",
557 entry->GetSharedTx()->GetId().ToString()));
558 return false;
559 }
560
561 // It is possible (and normal) that an ancestor is already finalized.
562 // Beware to not account for it in this case.
563 if (isAvalancheFinalized(entry->GetTx().GetId())) {
564 iter_it = setAncestors.erase(iter_it);
565 continue;
566 }
567
568 sumOfTxSize += entry->GetTxSize();
569 sumOfTxSigChecks += entry->GetSigChecks();
570 ++iter_it;
571 }
572
573 if (!m_finalizedTxsFitter.testTxFits(sumOfTxSize, sumOfTxSigChecks)) {
574 LogPrint(
576 "Delay storing finalized tx %s as it won't fit in the next block\n",
577 tx->GetTx().GetId().ToString());
578 return false;
579 }
580
581 finalizedTxIds.clear();
582
583 // Now let's add the txs !
584 // At this stage the set of ancestors is free if already finalized txs
585 for (txiter ancestor_it : setAncestors) {
586 if (finalizedTxs.insert(*ancestor_it)) {
587 m_finalizedTxsFitter.addTx((*ancestor_it)->GetTxSize(),
588 (*ancestor_it)->GetSigChecks(),
589 (*ancestor_it)->GetFee());
590
591 finalizedTxIds.push_back((*ancestor_it)->GetTx().GetId());
592 }
593 }
594
595 return true;
596}
597
601
602 const TxId &txid = tx->GetId();
603 if (auto it = GetIter(txid)) {
604 CTxMemPoolEntryRef entry = **it;
605
606 // The tx is in the mempool, check it would fit the next block or if
607 // it's already full of finalized txs.
608 return !m_finalizedTxsFitter.isBelowBlockMinFeeRate(
609 entry->GetModifiedFeeRate()) &&
610 m_finalizedTxsFitter.testTxFits(entry->GetTxSize(),
611 entry->GetSigChecks());
612 }
613
614 // Otherwise check if it's in the conflicting pool. If we reach this point
615 // this means that the transaction has been rejected so no need to check if
616 // it fits the block, however we don't want to discard it either so the vote
617 // continue until the tx is invalidated.
619 return m_conflicting && m_conflicting->HaveTx(txid));
620}
621
623 LOCK(cs);
624 indexed_transaction_set::const_iterator i = mapTx.find(txid);
625 if (i == mapTx.end()) {
626 return nullptr;
627 }
628
629 return (*i)->GetSharedTx();
630}
631
633 LOCK(cs);
634 indexed_transaction_set::const_iterator i = mapTx.find(txid);
635 if (i == mapTx.end()) {
636 return TxMempoolInfo();
637 }
638
639 return GetInfo(i);
640}
641
643 LOCK(cs);
644
645 // minerPolicy uses recent blocks to figure out a reasonable fee. This
646 // may disagree with the rollingMinimumFeerate under certain scenarios
647 // where the mempool increases rapidly, or blocks are being mined which
648 // do not contain propagated transactions.
649 return std::max(m_min_relay_feerate, GetMinFee());
650}
651
653 const Amount nFeeDelta) {
654 {
655 LOCK(cs);
656 Amount &delta = mapDeltas[txid];
657 delta += nFeeDelta;
658 txiter it = mapTx.find(txid);
659 if (it != mapTx.end()) {
660 mapTx.modify(it, [&delta](CTxMemPoolEntryRef &e) {
661 e->UpdateFeeDelta(delta);
662 });
664 }
665 }
666 LogPrintf("PrioritiseTransaction: %s fee += %s\n", txid.ToString(),
667 FormatMoney(nFeeDelta));
668}
669
670void CTxMemPool::ApplyDelta(const TxId &txid, Amount &nFeeDelta) const {
672 std::map<TxId, Amount>::const_iterator pos = mapDeltas.find(txid);
673 if (pos == mapDeltas.end()) {
674 return;
675 }
676
677 nFeeDelta += pos->second;
678}
679
682 mapDeltas.erase(txid);
683}
684
685CTransactionRef CTxMemPool::GetConflictTx(const COutPoint &prevout) const {
686 const auto it = mapNextTx.find(prevout);
687 return it == mapNextTx.end() ? nullptr : it->second;
688}
689
690std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const TxId &txid) const {
691 auto it = mapTx.find(txid);
692 if (it != mapTx.end()) {
693 return it;
694 }
695 return std::nullopt;
696}
697
699CTxMemPool::GetIterSet(const std::set<TxId> &txids) const {
701 for (const auto &txid : txids) {
702 const auto mi = GetIter(txid);
703 if (mi) {
704 ret.insert(*mi);
705 }
706 }
707 return ret;
708}
709
710bool CTxMemPool::HasNoInputsOf(const CTransaction &tx) const {
711 for (const CTxIn &in : tx.vin) {
712 if (exists(in.prevout.GetTxId())) {
713 return false;
714 }
715 }
716
717 return true;
718}
719
721 const CTxMemPool &mempoolIn)
722 : CCoinsViewBacked(baseIn), mempool(mempoolIn) {}
723
724bool CCoinsViewMemPool::GetCoin(const COutPoint &outpoint, Coin &coin) const {
725 // Check to see if the inputs are made available by another tx in the
726 // package. These Coins would not be available in the underlying CoinsView.
727 if (auto it = m_temp_added.find(outpoint); it != m_temp_added.end()) {
728 coin = it->second;
729 return true;
730 }
731
732 // If an entry in the mempool exists, always return that one, as it's
733 // guaranteed to never conflict with the underlying cache, and it cannot
734 // have pruned entries (as it contains full) transactions. First checking
735 // the underlying cache risks returning a pruned entry instead.
736 CTransactionRef ptx = mempool.get(outpoint.GetTxId());
737 if (ptx) {
738 if (outpoint.GetN() < ptx->vout.size()) {
739 coin = Coin(ptx->vout[outpoint.GetN()], MEMPOOL_HEIGHT, false);
740 m_non_base_coins.emplace(outpoint);
741 return true;
742 }
743 return false;
744 }
745 return base->GetCoin(outpoint, coin);
746}
747
749 for (uint32_t n = 0; n < tx->vout.size(); ++n) {
750 m_temp_added.emplace(COutPoint(tx->GetId(), n),
751 Coin(tx->vout[n], MEMPOOL_HEIGHT, false));
752 m_non_base_coins.emplace(COutPoint(tx->GetId(), n));
753 }
754}
756 m_temp_added.clear();
757 m_non_base_coins.clear();
758}
759
761 LOCK(cs);
762 // Estimate the overhead of mapTx to be 12 pointers + an allocation, as no
763 // exact formula for boost::multi_index_contained is implemented.
765 12 * sizeof(void *)) *
766 mapTx.size() +
767 memusage::DynamicUsage(mapNextTx) +
768 memusage::DynamicUsage(mapDeltas) + cachedInnerUsage;
769}
770
771void CTxMemPool::RemoveUnbroadcastTx(const TxId &txid, const bool unchecked) {
772 LOCK(cs);
773
774 if (m_unbroadcast_txids.erase(txid)) {
775 LogPrint(
776 BCLog::MEMPOOL, "Removed %i from set of unbroadcast txns%s\n",
777 txid.GetHex(),
778 (unchecked ? " before confirmation that txn was sent out" : ""));
779 }
780}
781
783 MemPoolRemovalReason reason) {
786
787 // Remove txs in reverse-topological order
788 const setRevTopoEntries stageRevTopo(stage.begin(), stage.end());
789 for (txiter it : stageRevTopo) {
790 removeUnchecked(it, reason);
791 }
792}
793
794int CTxMemPool::Expire(std::chrono::seconds time) {
796 indexed_transaction_set::index<entry_time>::type::iterator it =
797 mapTx.get<entry_time>().begin();
798 setEntries toremove;
799 size_t skippedFinalizedTxs{0};
800 while (it != mapTx.get<entry_time>().end() && (*it)->GetTime() < time) {
801 if (isAvalancheFinalized((*it)->GetTx().GetId())) {
802 // Don't expire finalized transactions
803 ++skippedFinalizedTxs;
804 } else {
805 toremove.insert(mapTx.project<0>(it));
806 }
807
808 it++;
809 }
810
811 if (skippedFinalizedTxs > 0) {
812 LogPrint(BCLog::MEMPOOL, "Not expiring %u finalized transaction\n",
813 skippedFinalizedTxs);
814 }
815
816 setEntries stage;
817 for (txiter removeit : toremove) {
818 CalculateDescendants(removeit, stage);
819 }
820
822 return stage.size();
823}
824
828 int expired = Expire(GetTime<std::chrono::seconds>() - m_expiry);
829 if (expired != 0) {
831 "Expired %i transactions from the memory pool\n", expired);
832 }
833
834 std::vector<COutPoint> vNoSpendsRemaining;
835 TrimToSize(m_max_size_bytes, &vNoSpendsRemaining);
836 for (const COutPoint &removed : vNoSpendsRemaining) {
837 coins_cache.Uncache(removed);
838 }
839}
840
841void CTxMemPool::UpdateChild(txiter entry, txiter child, bool add) {
844 if (add && (*entry)->GetMemPoolChildren().insert(*child).second) {
845 cachedInnerUsage += memusage::IncrementalDynamicUsage(s);
846 } else if (!add && (*entry)->GetMemPoolChildren().erase(*child)) {
847 cachedInnerUsage -= memusage::IncrementalDynamicUsage(s);
848 }
849}
850
851void CTxMemPool::UpdateParent(txiter entry, txiter parent, bool add) {
854 if (add && (*entry)->GetMemPoolParents().insert(*parent).second) {
855 cachedInnerUsage += memusage::IncrementalDynamicUsage(s);
856 } else if (!add && (*entry)->GetMemPoolParents().erase(*parent)) {
857 cachedInnerUsage -= memusage::IncrementalDynamicUsage(s);
858 }
859}
860
861CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
862 LOCK(cs);
863 if (!blockSinceLastRollingFeeBump || rollingMinimumFeeRate == 0) {
864 return CFeeRate(int64_t(ceill(rollingMinimumFeeRate)) * SATOSHI);
865 }
866
867 int64_t time = GetTime();
868 if (time > lastRollingFeeUpdate + 10) {
869 double halflife = ROLLING_FEE_HALFLIFE;
870 if (DynamicMemoryUsage() < sizelimit / 4) {
871 halflife /= 4;
872 } else if (DynamicMemoryUsage() < sizelimit / 2) {
873 halflife /= 2;
874 }
875
876 rollingMinimumFeeRate =
877 rollingMinimumFeeRate /
878 pow(2.0, (time - lastRollingFeeUpdate) / halflife);
879 lastRollingFeeUpdate = time;
880 }
881 return CFeeRate(int64_t(ceill(rollingMinimumFeeRate)) * SATOSHI);
882}
883
886 if ((rate.GetFeePerK() / SATOSHI) > rollingMinimumFeeRate) {
887 rollingMinimumFeeRate = rate.GetFeePerK() / SATOSHI;
888 blockSinceLastRollingFeeBump = false;
889 }
890}
891
892void CTxMemPool::TrimToSize(size_t sizelimit,
893 std::vector<COutPoint> *pvNoSpendsRemaining) {
895
896 unsigned nTxnRemoved = 0;
897 size_t finalizedTxsSkipped = 0;
898 CFeeRate maxFeeRateRemoved(Amount::zero());
899 while (!mapTx.empty() && DynamicMemoryUsage() > sizelimit) {
900 auto &by_modified_feerate = mapTx.get<modified_feerate>();
901 // Lowest fee first
902 auto rit = by_modified_feerate.rbegin();
903
904 // We don't evict finalized transactions, even if they have lower fee
905 while (isAvalancheFinalized((*rit)->GetTx().GetId())) {
906 ++finalizedTxsSkipped;
907 ++rit;
908 if (rit == by_modified_feerate.rend()) {
909 // Nothing we can trim
910 break;
911 }
912 }
913
914 // Convert to forward iterator.
915 // If rit == rend(), the forward iterator will be equivalent to begin()
916 // and we can't decrement it, there is nothing to remove. This could
917 // only happen if all the transactions are finalized, which in turns
918 // implies that the mempool cannot contain a block worth of txs.
919 // In this case we still exit the loop so we get the proper log message.
920 if (rit == by_modified_feerate.rend()) {
921 break;
922 }
923 auto it = rit.base();
924 --it;
925
926 // We set the new mempool min fee to the feerate of the removed
927 // transaction, plus the "minimum reasonable fee rate" (ie some value
928 // under which we consider txn to have 0 fee). This way, we don't allow
929 // txn to enter mempool with feerate equal to txn which were removed
930 // with no block in between.
931 CFeeRate removed = (*it)->GetModifiedFeeRate();
933
934 trackPackageRemoved(removed);
935 maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed);
936
937 setEntries stage;
938 CalculateDescendants(mapTx.project<0>(it), stage);
939 nTxnRemoved += stage.size();
940
941 if (pvNoSpendsRemaining) {
942 for (const txiter &iter : stage) {
943 for (const CTxIn &txin : (*iter)->GetTx().vin) {
944 if (!exists(txin.prevout.GetTxId())) {
945 pvNoSpendsRemaining->push_back(txin.prevout);
946 }
947 }
948 }
949 }
950
952 }
953
954 if (maxFeeRateRemoved > CFeeRate(Amount::zero())) {
956 "Removed %u txn, rolling minimum fee bumped to %s\n",
957 nTxnRemoved, maxFeeRateRemoved.ToString());
958 }
959
960 if (finalizedTxsSkipped > 0) {
962 "Not evicting %u finalized txn for low fee\n",
963 finalizedTxsSkipped);
964 }
965}
966
968 LOCK(cs);
969 return m_load_tried;
970}
971
972void CTxMemPool::SetLoadTried(bool load_tried) {
973 LOCK(cs);
974 m_load_tried = load_tried;
975}
976
977std::string RemovalReasonToString(const MemPoolRemovalReason &r) noexcept {
978 switch (r) {
980 return "expiry";
982 return "sizelimit";
984 return "reorg";
986 return "block";
988 return "conflict";
990 return "avalanche";
991 }
992 assert(false);
993}
static constexpr Amount SATOSHI
Definition: amount.h:143
#define Assume(val)
Assume is the identity function.
Definition: check.h:97
CCoinsView backed by another CCoinsView.
Definition: coins.h:201
CCoinsView * base
Definition: coins.h:203
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:221
void Uncache(const COutPoint &outpoint)
Removes the UTXO with the given outpoint from the cache, if it is not modified.
Definition: coins.cpp:330
Abstract view on the open txout dataset.
Definition: coins.h:163
virtual bool GetCoin(const COutPoint &outpoint, Coin &coin) const
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: coins.cpp:13
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
GetCoin, returning whether it exists and is not spent.
Definition: txmempool.cpp:724
void Reset()
Clear m_temp_added and m_non_base_coins.
Definition: txmempool.cpp:755
std::unordered_map< COutPoint, Coin, SaltedOutpointHasher > m_temp_added
Coins made available by transactions being validated.
Definition: txmempool.h:642
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn)
Definition: txmempool.cpp:720
std::unordered_set< COutPoint, SaltedOutpointHasher > m_non_base_coins
Set of all coins that have been fetched from mempool or created using PackageAddTransaction (not base...
Definition: txmempool.h:650
void PackageAddTransaction(const CTransactionRef &tx)
Add the coins created by this transaction.
Definition: txmempool.cpp:748
const CTxMemPool & mempool
Definition: txmempool.h:653
Fee rate in satoshis per kilobyte: Amount / kB.
Definition: feerate.h:21
std::string ToString() const
Definition: feerate.cpp:57
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
Definition: feerate.h:54
void TransactionRemovedFromMempool(const CTransactionRef &, MemPoolRemovalReason, uint64_t mempool_sequence)
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition: mempool_entry.h:65
std::set< std::reference_wrapper< const CTxMemPoolEntryRef >, CompareIteratorById > Children
Definition: mempool_entry.h:73
std::set< std::reference_wrapper< const CTxMemPoolEntryRef >, CompareIteratorById > Parents
Definition: mempool_entry.h:70
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:214
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:300
CFeeRate estimateFee() const
Definition: txmempool.cpp:642
bool HasNoInputsOf(const CTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Check that none of this transactions inputs are in the mempool, and thus the tx is not dependent on o...
Definition: txmempool.cpp:710
void ClearPrioritisation(const TxId &txid) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:680
std::set< txiter, CompareIteratorById > setEntries
Definition: txmempool.h:314
void RemoveUnbroadcastTx(const TxId &txid, const bool unchecked=false)
Removes a transaction from the unbroadcast set.
Definition: txmempool.cpp:771
bool GetLoadTried() const
Definition: txmempool.cpp:967
bool CalculateAncestors(setEntries &setAncestors, CTxMemPoolEntry::Parents &staged_ancestors) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Helper function to calculate all in-mempool ancestors of staged_ancestors param@[in] staged_ancestors...
Definition: txmempool.cpp:31
void updateFeeForBlock() EXCLUSIVE_LOCKS_REQUIRED(cs)
Called when a block is connected.
Definition: txmempool.cpp:321
CFeeRate GetMinFee() const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
Definition: txmempool.h:454
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition: txmempool.h:310
void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:884
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:269
void UpdateForRemoveFromMempool(const setEntries &entriesToRemove) EXCLUSIVE_LOCKS_REQUIRED(cs)
For each transaction being removed, update ancestors and any direct children.
Definition: txmempool.cpp:103
const int m_check_ratio
Value n means that 1 times in n we check.
Definition: txmempool.h:217
void TrimToSize(size_t sizelimit, std::vector< COutPoint > *pvNoSpendsRemaining=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove transactions from the mempool until its dynamic size is <= sizelimit.
Definition: txmempool.cpp:892
const std::chrono::seconds m_expiry
Definition: txmempool.h:348
void AddTransactionsUpdated(unsigned int n)
Definition: txmempool.cpp:145
void UpdateChildrenForRemoval(txiter entry) EXCLUSIVE_LOCKS_REQUIRED(cs)
Sever link between specified transaction and direct children.
Definition: txmempool.cpp:93
bool CompareTopologically(const TxId &txida, const TxId &txidb) const
Definition: txmempool.cpp:476
TxMempoolInfo info(const TxId &txid) const
Definition: txmempool.cpp:632
const int64_t m_max_size_bytes
Definition: txmempool.h:347
void getAllTxIds(std::vector< TxId > &vtxid) const
Definition: txmempool.cpp:490
std::atomic< uint32_t > nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
Definition: txmempool.h:219
setEntries GetIterSet(const std::set< TxId > &txids) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Translate a set of txids into a set of pool iterators to avoid repeated lookups.
Definition: txmempool.cpp:699
size_t DynamicMemoryUsage() const
Definition: txmempool.cpp:760
std::vector< TxMempoolInfo > infoAll() const
Definition: txmempool.cpp:508
void LimitSize(CCoinsViewCache &coins_cache) EXCLUSIVE_LOCKS_REQUIRED(cs
Reduce the size of the mempool by expiring and then trimming the mempool.
Definition: txmempool.cpp:825
void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:851
bool setAvalancheFinalized(const CTxMemPoolEntryRef &tx, std::vector< TxId > &finalizedTxIds) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:522
CTransactionRef GetConflictTx(const COutPoint &prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Get the transaction in the pool that spends the same prevout.
Definition: txmempool.cpp:685
void removeUnchecked(txiter entry, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Before calling removeUnchecked for a given transaction, UpdateForRemoveFromMempool must be called on ...
Definition: txmempool.cpp:197
int Expire(std::chrono::seconds time) EXCLUSIVE_LOCKS_REQUIRED(cs)
Expire all transaction (and their dependencies) in the mempool older than time.
Definition: txmempool.cpp:794
void clear()
Definition: txmempool.cpp:357
bool isWorthPolling(const CTransactionRef &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs
Definition: txmempool.cpp:598
std::set< txiter, CompareIteratorByRevEntryId > setRevTopoEntries
Definition: txmempool.h:315
bool exists(const TxId &txid) const
Definition: txmempool.h:521
static const int ROLLING_FEE_HALFLIFE
Definition: txmempool.h:259
CTransactionRef get(const TxId &txid) const
Definition: txmempool.cpp:622
bool isAvalancheFinalized(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:530
const CFeeRate m_min_relay_feerate
Definition: txmempool.h:349
void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
Definition: txmempool.cpp:652
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
Definition: txmempool.h:313
uint64_t GetAndIncrementSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Guards this internal counter for external reporting.
Definition: txmempool.h:570
void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:841
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void addUnchecked(CTxMemPoolEntryRef entry) EXCLUSIVE_LOCKS_REQUIRED(cs
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
Definition: txmempool.h:375
RadixTree< CTxMemPoolEntry, MemPoolEntryRadixTreeAdapter > finalizedTxs
Definition: txmempool.h:317
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void cs_main
Definition: txmempool.h:376
bool CalculateMemPoolAncestors(const CTxMemPoolEntryRef &entry, setEntries &setAncestors, bool fSearchForParents=true) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Try to calculate all in-mempool ancestors of entry.
Definition: txmempool.cpp:58
void removeForFinalizedBlock(const std::vector< CTransactionRef > &vtx) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:328
Mutex cs_conflicting
Definition: txmempool.h:253
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of hash.
Definition: txmempool.cpp:242
void RemoveStaged(const setEntries &stage, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove a set of transactions from the mempool.
Definition: txmempool.cpp:782
CTxMemPool(const Config &config, const Options &opts)
Create a new CTxMemPool.
Definition: txmempool.cpp:119
void UpdateParentsOf(bool add, txiter it) EXCLUSIVE_LOCKS_REQUIRED(cs)
Update parents of it to add/remove it as a child transaction.
Definition: txmempool.cpp:84
void ApplyDelta(const TxId &txid, Amount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:670
void SetLoadTried(bool load_tried)
Set whether or not we've made an attempt to load the mempool (regardless of whether the attempt was s...
Definition: txmempool.cpp:972
std::optional< txiter > GetIter(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given txid, if found.
Definition: txmempool.cpp:690
bool isSpent(const COutPoint &outpoint) const
Definition: txmempool.cpp:136
unsigned int GetTransactionsUpdated() const
Definition: txmempool.cpp:141
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:345
A UTXO entry.
Definition: coins.h:28
Definition: config.h:19
Definition: rcu.h:85
T * get()
Get allows to access the undelying pointer.
Definition: rcu.h:170
std::string ToString() const
Definition: uint256.h:80
std::string GetHex() const
Definition: uint256.cpp:16
void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, bool check_for_overwrite)
Utility function to add all of a transaction's outputs to a cache.
Definition: coins.cpp:156
#define LogPrint(category,...)
Definition: logging.h:238
#define LogPrintf(...)
Definition: logging.h:227
std::string FormatMoney(const Amount amt)
Do not use these functions to represent or parse monetary amounts to or from JSON but use AmountFromV...
Definition: moneystr.cpp:13
@ AVALANCHE
Definition: logging.h:62
@ MEMPOOL
Definition: logging.h:42
bool CheckTxInputs(const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight, Amount &txfee)
Check whether all inputs of this transaction are valid (no double spends and amounts).
Definition: tx_verify.cpp:168
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
Definition: memusage.h:27
static size_t IncrementalDynamicUsage(const std::set< X, Y > &s)
Definition: memusage.h:123
static size_t MallocUsage(size_t alloc)
Compute the total memory used by allocating alloc bytes.
Definition: memusage.h:73
Definition: init.h:31
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition: rcu.h:259
static constexpr CFeeRate MEMPOOL_FULL_FEE_INCREMENT(1000 *SATOSHI)
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP...
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:315
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition: random.h:85
Definition: amount.h:19
static constexpr Amount zero() noexcept
Definition: amount.h:32
RCUPtr< T > remove(const KeyType &key)
Remove an element from the tree.
Definition: radix.h:181
bool insert(const RCUPtr< T > &value)
Insert a value into the tree.
Definition: radix.h:112
A TxId is the identifier of a transaction.
Definition: txid.h:14
Information about a mempool transaction.
Definition: txmempool.h:132
Options struct containing options for constructing a CTxMemPool.
#define AssertLockNotHeld(cs)
Definition: sync.h:163
#define LOCK(cs)
Definition: sync.h:306
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition: sync.h:357
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
Definition: time.cpp:109
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1202
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:68
std::string RemovalReasonToString(const MemPoolRemovalReason &r) noexcept
Definition: txmempool.cpp:977
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it)
Definition: txmempool.cpp:502
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:153
@ SIZELIMIT
Removed in size limiting.
@ BLOCK
Removed for block.
@ EXPIRY
Expired from mempool.
@ AVALANCHE
Removed by avalanche vote.
@ CONFLICT
Removed for conflict with in-block transaction.
@ REORG
Removed for reorganization.
static const uint32_t MEMPOOL_HEIGHT
Fake height value used in Coins to signify they are only in the memory pool(since 0....
Definition: txmempool.h:50
AssertLockHeld(pool.cs)
assert(!tx.IsCoinBase())
CMainSignals & GetMainSignals()