Bitcoin ABC  0.29.6
P2P Digital Currency
txmempool.h
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 #ifndef BITCOIN_TXMEMPOOL_H
7 #define BITCOIN_TXMEMPOOL_H
8 
9 #include <coins.h>
10 #include <consensus/amount.h>
11 #include <core_memusage.h>
12 #include <indirectmap.h>
13 #include <kernel/cs_main.h>
14 #include <kernel/mempool_entry.h>
15 #include <kernel/mempool_options.h>
16 #include <policy/packages.h>
17 #include <primitives/transaction.h>
18 #include <radix.h>
19 #include <sync.h>
20 #include <uint256radixkey.h>
21 #include <util/hasher.h>
22 
23 #include <boost/multi_index/hashed_index.hpp>
24 #include <boost/multi_index/ordered_index.hpp>
25 #include <boost/multi_index/sequenced_index.hpp>
26 #include <boost/multi_index_container.hpp>
27 
28 #include <atomic>
29 #include <map>
30 #include <optional>
31 #include <set>
32 #include <string>
33 #include <unordered_map>
34 #include <utility>
35 #include <vector>
36 
37 class CChain;
38 class Chainstate;
39 class Config;
40 
45 static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
46 
47 // extracts a transaction id from CTxMemPoolEntry or CTransactionRef
49  typedef TxId result_type;
50 
52  return entry->GetTx().GetId();
53  }
54 
56  return tx->GetId();
57  }
58 };
59 
64  Uint256RadixKey getId(const CTxMemPoolEntry &entry) const {
65  return entry.GetSharedTx()->GetId();
66  }
67 };
68 
69 // used by the entry_time index
72  const CTxMemPoolEntryRef &b) const {
73  return a->GetTime() < b->GetTime();
74  }
75 };
76 
77 // used by the entry_id index
80  const CTxMemPoolEntryRef &b) const {
81  return a->GetEntryId() < b->GetEntryId();
82  }
83 };
84 
92  // Used in tests
93  bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const {
94  const CFeeRate frA = a.GetModifiedFeeRate();
95  const CFeeRate frB = b.GetModifiedFeeRate();
96 
97  // Sort by modified fee rate first
98  if (frA != frB) {
99  return frA > frB;
100  }
101 
102  // Ties are broken by whichever is topologically earlier
103  // (this helps mining code avoid some backtracking).
104  if (a.GetEntryId() != b.GetEntryId()) {
105  return a.GetEntryId() < b.GetEntryId();
106  }
107 
108  // If nothing else, sort by txid (this should never happen as entryID is
109  // expected to be unique).
110  return a.GetSharedTx()->GetId() < b.GetSharedTx()->GetId();
111  }
112 
114  const CTxMemPoolEntryRef &b) const {
115  return operator()(*a, *b);
116  }
117 };
118 
119 // Multi_index tag names
120 struct entry_time {};
122 struct entry_id {};
123 
130 
132  std::chrono::seconds m_time;
133 
136 
138  size_t vsize;
139 
142 };
143 
150  EXPIRY,
152  SIZELIMIT,
154  REORG,
156  BLOCK,
158  CONFLICT,
160  AVALANCHE,
161 };
162 
163 const std::string RemovalReasonToString(const MemPoolRemovalReason &r) noexcept;
164 
209 class CTxMemPool {
210 private:
212  const int m_check_ratio;
214  std::atomic<uint32_t> nTransactionsUpdated{0};
215 
217  uint64_t totalTxSize GUARDED_BY(cs);
219  Amount m_total_fee GUARDED_BY(cs);
222  uint64_t cachedInnerUsage GUARDED_BY(cs);
223 
224  mutable int64_t lastRollingFeeUpdate GUARDED_BY(cs);
225  mutable bool blockSinceLastRollingFeeBump GUARDED_BY(cs);
227  mutable double rollingMinimumFeeRate GUARDED_BY(cs);
228 
229  // In-memory counter for external mempool tracking purposes.
230  // This number is incremented once every time a transaction
231  // is added or removed from the mempool for any reason.
232  mutable uint64_t m_sequence_number GUARDED_BY(cs){1};
233 
235 
236  bool m_load_tried GUARDED_BY(cs){false};
237 
240  uint64_t nextEntryId GUARDED_BY(cs) = 1;
241 
242 public:
243  // public only for testing
244  static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12;
245 
246  typedef boost::multi_index_container<
248  boost::multi_index::indexed_by<
249  // indexed by txid
250  boost::multi_index::hashed_unique<mempoolentry_txid,
252  // sorted by fee rate
253  boost::multi_index::ordered_non_unique<
254  boost::multi_index::tag<modified_feerate>,
255  boost::multi_index::identity<CTxMemPoolEntryRef>,
257  // sorted by entry time
258  boost::multi_index::ordered_non_unique<
259  boost::multi_index::tag<entry_time>,
260  boost::multi_index::identity<CTxMemPoolEntryRef>,
262  // sorted topologically (insertion order)
263  boost::multi_index::ordered_unique<
264  boost::multi_index::tag<entry_id>,
265  boost::multi_index::identity<CTxMemPoolEntryRef>,
268 
298 
299  using txiter = indexed_transaction_set::nth_index<0>::type::const_iterator;
300  typedef std::set<txiter, CompareIteratorById> setEntries;
301  typedef std::set<txiter, CompareIteratorByRevEntryId> setRevTopoEntries;
302 
304 
305 private:
306  void UpdateParent(txiter entry, txiter parent, bool add)
308  void UpdateChild(txiter entry, txiter child, bool add)
310 
315  std::set<TxId> m_unbroadcast_txids GUARDED_BY(cs);
316 
323  bool CalculateAncestors(setEntries &setAncestors,
324  CTxMemPoolEntry::Parents &staged_ancestors) const
326 
327 public:
329  std::map<TxId, Amount> mapDeltas GUARDED_BY(cs);
330 
332 
333  const int64_t m_max_size_bytes;
334  const std::chrono::seconds m_expiry;
338  const std::optional<unsigned> m_max_datacarrier_bytes;
339  const bool m_require_standard;
340 
347  CTxMemPool(const Options &opts);
348  ~CTxMemPool();
349 
356  void check(const CCoinsViewCache &active_coins_tip,
357  int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
358 
359  // addUnchecked must update state for all parents of a given transaction,
360  // updating child links as necessary.
363 
364  void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason)
368  void removeForFinalizedBlock(const std::vector<CTransactionRef> &vtx)
370 
371  void clear();
372  // lock free
374  bool CompareTopologically(const TxId &txida, const TxId &txidb) const;
375  void getAllTxIds(std::vector<TxId> &vtxid) const;
376  bool isSpent(const COutPoint &outpoint) const;
377  unsigned int GetTransactionsUpdated() const;
378  void AddTransactionsUpdated(unsigned int n);
384  bool HasNoInputsOf(const CTransaction &tx) const
386 
388  void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta);
389  void ApplyDelta(const TxId &txid, Amount &nFeeDelta) const
392 
394  const CTransaction *GetConflictTx(const COutPoint &prevout) const
396 
398  std::optional<txiter> GetIter(const TxId &txid) const
400 
405  setEntries GetIterSet(const std::set<TxId> &txids) const
407 
413  void RemoveStaged(const setEntries &stage, MemPoolRemovalReason reason)
415 
424  setEntries &setAncestors,
425  bool fSearchForParents = true) const
427 
433  void CalculateDescendants(txiter it, setEntries &setDescendants) const
435 
441  CFeeRate GetMinFee(size_t sizelimit) const;
442 
449  void TrimToSize(size_t sizelimit,
450  std::vector<COutPoint> *pvNoSpendsRemaining = nullptr)
452 
457  int Expire(std::chrono::seconds time) EXCLUSIVE_LOCKS_REQUIRED(cs);
458 
462  void LimitSize(CCoinsViewCache &coins_cache)
464 
469  bool GetLoadTried() const;
470 
475  void SetLoadTried(bool load_tried);
476 
477  unsigned long size() const {
478  LOCK(cs);
479  return mapTx.size();
480  }
481 
484  return totalTxSize;
485  }
486 
489  return m_total_fee;
490  }
491 
492  bool exists(const TxId &txid) const {
493  LOCK(cs);
494  return mapTx.count(txid) != 0;
495  }
496 
499  return finalizedTxs.insert(tx);
500  }
501 
502  bool isAvalancheFinalized(const TxId &txid) const {
503  LOCK(cs);
504  return finalizedTxs.get(txid) != nullptr;
505  }
506 
507  CTransactionRef get(const TxId &txid) const;
508  TxMempoolInfo info(const TxId &txid) const;
509  std::vector<TxMempoolInfo> infoAll() const;
510 
511  CFeeRate estimateFee() const;
512 
513  size_t DynamicMemoryUsage() const;
514 
516  void AddUnbroadcastTx(const TxId &txid) {
517  LOCK(cs);
518  // Sanity check the transaction is in the mempool & insert into
519  // unbroadcast set.
520  if (exists(txid)) {
521  m_unbroadcast_txids.insert(txid);
522  }
523  }
524 
526  void RemoveUnbroadcastTx(const TxId &txid, const bool unchecked = false);
527 
529  std::set<TxId> GetUnbroadcastTxs() const {
530  LOCK(cs);
531  return m_unbroadcast_txids;
532  }
533 
535  bool IsUnbroadcastTx(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs) {
537  return (m_unbroadcast_txids.count(txid) != 0);
538  }
539 
542  return m_sequence_number++;
543  }
544 
546  return m_sequence_number;
547  }
548 
549 private:
551  void UpdateEntryForAncestors(txiter it, const setEntries *setAncestors)
561  void UpdateForRemoveFromMempool(const setEntries &entriesToRemove)
565 
574  void removeUnchecked(txiter entry, MemPoolRemovalReason reason)
576 };
577 
597  std::unordered_map<COutPoint, Coin, SaltedOutpointHasher> m_temp_added;
598 
599 protected:
601 
602 public:
603  CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn);
604  bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
610  void PackageAddTransaction(const CTransactionRef &tx);
611 };
612 
613 #endif // BITCOIN_TXMEMPOOL_H
An in-memory indexed chain of blocks.
Definition: chain.h:134
CCoinsView backed by another CCoinsView.
Definition: coins.h:201
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:221
Abstract view on the open txout dataset.
Definition: coins.h:163
CCoinsView that brings transactions from a mempool into view.
Definition: txmempool.h:591
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: txmempool.cpp:607
std::unordered_map< COutPoint, Coin, SaltedOutpointHasher > m_temp_added
Coins made available by transactions being validated.
Definition: txmempool.h:597
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn)
Definition: txmempool.cpp:603
void PackageAddTransaction(const CTransactionRef &tx)
Add the coins created by this transaction.
Definition: txmempool.cpp:630
const CTxMemPool & mempool
Definition: txmempool.h:600
Fee rate in satoshis per kilobyte: Amount / kB.
Definition: feerate.h:21
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:20
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:192
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition: mempool_entry.h:65
uint64_t GetEntryId() const
CTransactionRef GetSharedTx() const
CFeeRate GetModifiedFeeRate() const
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:209
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:290
bool isAvalancheFinalized(const TxId &txid) const
Definition: txmempool.h:502
CFeeRate estimateFee() const
Definition: txmempool.cpp:525
uint64_t nextEntryId GUARDED_BY(cs)
Used by addUnchecked to generate ever-increasing CTxMemPoolEntry::entryId's.
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:593
void ClearPrioritisation(const TxId &txid) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:563
std::set< txiter, CompareIteratorById > setEntries
Definition: txmempool.h:300
const bool m_require_standard
Definition: txmempool.h:339
void RemoveUnbroadcastTx(const TxId &txid, const bool unchecked=false)
Removes a transaction from the unbroadcast set.
Definition: txmempool.cpp:648
uint64_t cachedInnerUsage GUARDED_BY(cs)
sum of dynamic memory usage of all the map elements (NOT the maps themselves)
Amount m_total_fee GUARDED_BY(cs)
sum of all mempool tx's fees (NOT modified fee)
bool GetLoadTried() const
Definition: txmempool.cpp:802
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:29
void updateFeeForBlock() EXCLUSIVE_LOCKS_REQUIRED(cs)
Called when a block is connected.
Definition: txmempool.cpp:308
void UpdateEntryForAncestors(txiter it, const setEntries *setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs)
Set ancestor state for an entry.
CFeeRate GetMinFee() const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
Definition: txmempool.h:440
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition: txmempool.h:296
void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:749
Amount GetTotalFee() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:487
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:259
void UpdateForRemoveFromMempool(const setEntries &entriesToRemove) EXCLUSIVE_LOCKS_REQUIRED(cs)
For each transaction being removed, update ancestors and any direct children.
Definition: txmempool.cpp:101
bool blockSinceLastRollingFeeBump GUARDED_BY(cs)
const int m_check_ratio
Value n means that 1 times in n we check.
Definition: txmempool.h:212
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:757
const std::chrono::seconds m_expiry
Definition: txmempool.h:334
const std::optional< unsigned > m_max_datacarrier_bytes
Definition: txmempool.h:338
void AddTransactionsUpdated(unsigned int n)
Definition: txmempool.cpp:139
void UpdateChildrenForRemoval(txiter entry) EXCLUSIVE_LOCKS_REQUIRED(cs)
Sever link between specified transaction and direct children.
Definition: txmempool.cpp:91
bool CompareTopologically(const TxId &txida, const TxId &txidb) const
Definition: txmempool.cpp:459
TxMempoolInfo info(const TxId &txid) const
Definition: txmempool.cpp:515
const int64_t m_max_size_bytes
Definition: txmempool.h:333
void getAllTxIds(std::vector< TxId > &vtxid) const
Definition: txmempool.cpp:473
std::atomic< uint32_t > nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
Definition: txmempool.h:214
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:582
size_t DynamicMemoryUsage() const
Definition: txmempool.cpp:637
std::vector< TxMempoolInfo > infoAll() const
Definition: txmempool.cpp:491
indexed_transaction_set mapTx GUARDED_BY(cs)
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:690
bool setAvalancheFinalized(const CTxMemPoolEntryRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:497
void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:716
indirectmap< COutPoint, const CTransaction * > mapNextTx GUARDED_BY(cs)
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:191
uint64_t totalTxSize GUARDED_BY(cs)
sum of all mempool tx's sizes.
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:671
void clear()
Definition: txmempool.cpp:340
std::set< txiter, CompareIteratorByRevEntryId > setRevTopoEntries
Definition: txmempool.h:301
bool exists(const TxId &txid) const
Definition: txmempool.h:492
std::map< TxId, Amount > mapDeltas GUARDED_BY(cs)
int64_t lastRollingFeeUpdate GUARDED_BY(cs)
const bool m_permit_bare_multisig
Definition: txmempool.h:337
bool m_load_tried GUARDED_BY(cs)
Definition: txmempool.h:236
static const int ROLLING_FEE_HALFLIFE
Definition: txmempool.h:244
CTransactionRef get(const TxId &txid) const
Definition: txmempool.cpp:505
boost::multi_index_container< CTxMemPoolEntryRef, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< mempoolentry_txid, SaltedTxIdHasher >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< modified_feerate >, boost::multi_index::identity< CTxMemPoolEntryRef >, CompareTxMemPoolEntryByModifiedFeeRate >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< entry_time >, boost::multi_index::identity< CTxMemPoolEntryRef >, CompareTxMemPoolEntryByEntryTime >, boost::multi_index::ordered_unique< boost::multi_index::tag< entry_id >, boost::multi_index::identity< CTxMemPoolEntryRef >, CompareTxMemPoolEntryByEntryId > > > indexed_transaction_set
Definition: txmempool.h:267
const CFeeRate m_min_relay_feerate
Definition: txmempool.h:335
void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
Definition: txmempool.cpp:535
std::set< TxId > m_unbroadcast_txids GUARDED_BY(cs)
Track locally submitted transactions to periodically retry initial broadcast.
uint64_t GetSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:545
bool IsUnbroadcastTx(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns whether a txid is in the unbroadcast set.
Definition: txmempool.h:535
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
Definition: txmempool.h:299
uint64_t GetAndIncrementSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Guards this internal counter for external reporting.
Definition: txmempool.h:541
void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:706
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:361
RadixTree< CTxMemPoolEntry, MemPoolEntryRadixTreeAdapter > finalizedTxs
Definition: txmempool.h:303
double rollingMinimumFeeRate GUARDED_BY(cs)
minimum fee to get into the pool, decreases exponentially
CTxMemPool(const Options &opts)
Create a new CTxMemPool.
Definition: txmempool.cpp:117
const CTransaction * GetConflictTx(const COutPoint &prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Get the transaction in the pool that spends the same prevout.
Definition: txmempool.cpp:568
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:56
std::set< TxId > GetUnbroadcastTxs() const
Returns transactions in unbroadcast set.
Definition: txmempool.h:529
void removeForFinalizedBlock(const std::vector< CTransactionRef > &vtx) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:315
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of hash.
Definition: txmempool.cpp:232
void RemoveStaged(const setEntries &stage, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove a set of transactions from the mempool.
Definition: txmempool.cpp:659
unsigned long size() const
Definition: txmempool.h:477
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:82
uint64_t m_sequence_number GUARDED_BY(cs)
Definition: txmempool.h:232
void ApplyDelta(const TxId &txid, Amount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:553
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:807
const CFeeRate m_dust_relay_feerate
Definition: txmempool.h:336
std::optional< txiter > GetIter(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given txid, if found.
Definition: txmempool.cpp:573
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void cs_main
Definition: txmempool.h:362
uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:482
bool isSpent(const COutPoint &outpoint) const
Definition: txmempool.cpp:130
void AddUnbroadcastTx(const TxId &txid)
Adds a transaction to the unbroadcast set.
Definition: txmempool.h:516
unsigned int GetTransactionsUpdated() const
Definition: txmempool.cpp:135
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:328
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:631
A UTXO entry.
Definition: coins.h:28
Definition: config.h:19
Definition: rcu.h:85
Map whose keys are pointers, but are compared by their dereferenced values.
Definition: indirectmap.h:26
RCUPtr< CTxMemPoolEntry > CTxMemPoolEntryRef
Definition: mempool_entry.h:56
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition: rcu.h:257
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:315
Definition: amount.h:19
Definition: txmempool.h:78
bool operator()(const CTxMemPoolEntryRef &a, const CTxMemPoolEntryRef &b) const
Definition: txmempool.h:79
Definition: txmempool.h:70
bool operator()(const CTxMemPoolEntryRef &a, const CTxMemPoolEntryRef &b) const
Definition: txmempool.h:71
Sort by feerate of entry (modfee/vsize) in descending order.
Definition: txmempool.h:91
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:93
bool operator()(const CTxMemPoolEntryRef &a, const CTxMemPoolEntryRef &b) const
Definition: txmempool.h:113
Radix tree adapter for storing a CTxMemPoolEntry as a tree element.
Definition: txmempool.h:63
Uint256RadixKey getId(const CTxMemPoolEntry &entry) const
Definition: txmempool.h:64
RCUPtr< T > get(const KeyType &key)
Get the value corresponding to a key.
Definition: radix.h:118
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:127
Amount fee
Fee of the transaction.
Definition: txmempool.h:135
Amount nFeeDelta
The fee delta.
Definition: txmempool.h:141
CTransactionRef tx
The transaction itself.
Definition: txmempool.h:129
std::chrono::seconds m_time
Time the transaction entered the mempool.
Definition: txmempool.h:132
size_t vsize
Virtual size of the transaction.
Definition: txmempool.h:138
Facility for using an uint256 as a radix tree key.
Options struct containing options for constructing a CTxMemPool.
result_type operator()(const CTxMemPoolEntryRef &entry) const
Definition: txmempool.h:51
result_type operator()(const CTransactionRef &tx) const
Definition: txmempool.h:55
#define LOCK(cs)
Definition: sync.h:306
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:56
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:148
@ SIZELIMIT
Removed in size limiting.
@ BLOCK
Removed for block.
@ EXPIRY
Expired from mempool.
@ 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:45
const std::string RemovalReasonToString(const MemPoolRemovalReason &r) noexcept
Definition: txmempool.cpp:813
AssertLockHeld(pool.cs)