Bitcoin Core  22.99.0
P2P Digital Currency
txmempool.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2021 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 <atomic>
10 #include <map>
11 #include <optional>
12 #include <set>
13 #include <string>
14 #include <utility>
15 #include <vector>
16 
17 #include <coins.h>
18 #include <consensus/amount.h>
19 #include <indirectmap.h>
20 #include <policy/feerate.h>
21 #include <policy/packages.h>
22 #include <primitives/transaction.h>
23 #include <random.h>
24 #include <sync.h>
25 #include <util/epochguard.h>
26 #include <util/hasher.h>
27 
28 #include <boost/multi_index/hashed_index.hpp>
29 #include <boost/multi_index/ordered_index.hpp>
30 #include <boost/multi_index/sequenced_index.hpp>
31 #include <boost/multi_index_container.hpp>
32 
33 class CBlockIndex;
34 class CChain;
35 class CChainState;
36 extern RecursiveMutex cs_main;
37 
39 static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
40 
41 struct LockPoints {
42  // Will be set to the blockchain height and median time past
43  // values that would be necessary to satisfy all relative locktime
44  // constraints (BIP68) of this tx given our view of block chain history
45  int height{0};
46  int64_t time{0};
47  // As long as the current chain descends from the highest height block
48  // containing one of the inputs used in the calculation, then the cached
49  // values are still valid even after a reorg.
51 };
52 
57 
59  // SFINAE for T where T is either a pointer type (e.g., a txiter) or a reference_wrapper<T>
60  // (e.g. a wrapped CTxMemPoolEntry&)
61  template <typename T>
62  bool operator()(const std::reference_wrapper<T>& a, const std::reference_wrapper<T>& b) const
63  {
64  return a.get().GetTx().GetHash() < b.get().GetTx().GetHash();
65  }
66  template <typename T>
67  bool operator()(const T& a, const T& b) const
68  {
69  return a->GetTx().GetHash() < b->GetTx().GetHash();
70  }
71 };
72 
86 {
87 public:
88  typedef std::reference_wrapper<const CTxMemPoolEntry> CTxMemPoolEntryRef;
89  // two aliases, should the types ever diverge
90  typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> Parents;
91  typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> Children;
92 
93 private:
95  mutable Parents m_parents;
97  const CAmount nFee;
98  const size_t nTxWeight;
99  const size_t nUsageSize;
100  const int64_t nTime;
101  const unsigned int entryHeight;
102  const bool spendsCoinbase;
103  const int64_t sigOpCost;
104  int64_t feeDelta{0};
106 
107  // Information about descendants of this transaction that are in the
108  // mempool; if we remove this transaction we must remove all of these
109  // descendants as well.
110  uint64_t nCountWithDescendants{1};
113 
114  // Analogous statistics for ancestor transactions
115  uint64_t nCountWithAncestors{1};
119 
120 public:
122  int64_t time, unsigned int entry_height,
123  bool spends_coinbase,
124  int64_t sigops_cost, LockPoints lp);
125 
126  const CTransaction& GetTx() const { return *this->tx; }
127  CTransactionRef GetSharedTx() const { return this->tx; }
128  const CAmount& GetFee() const { return nFee; }
129  size_t GetTxSize() const;
130  size_t GetTxWeight() const { return nTxWeight; }
131  std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
132  unsigned int GetHeight() const { return entryHeight; }
133  int64_t GetSigOpCost() const { return sigOpCost; }
134  int64_t GetModifiedFee() const { return nFee + feeDelta; }
135  size_t DynamicMemoryUsage() const { return nUsageSize; }
136  const LockPoints& GetLockPoints() const { return lockPoints; }
137 
138  // Adjusts the descendant state.
139  void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount);
140  // Adjusts the ancestor state
141  void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps);
142  // Updates the fee delta used for mining priority score, and the
143  // modified fees with descendants.
144  void UpdateFeeDelta(int64_t feeDelta);
145  // Update the LockPoints after a reorg
146  void UpdateLockPoints(const LockPoints& lp);
147 
148  uint64_t GetCountWithDescendants() const { return nCountWithDescendants; }
149  uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
151 
152  bool GetSpendsCoinbase() const { return spendsCoinbase; }
153 
154  uint64_t GetCountWithAncestors() const { return nCountWithAncestors; }
155  uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
158 
159  const Parents& GetMemPoolParentsConst() const { return m_parents; }
160  const Children& GetMemPoolChildrenConst() const { return m_children; }
161  Parents& GetMemPoolParents() const { return m_parents; }
163 
164  mutable size_t vTxHashesIdx;
166 };
167 
168 // extracts a transaction hash from CTxMemPoolEntry or CTransactionRef
170 {
173  {
174  return entry.GetTx().GetHash();
175  }
176 
178  {
179  return tx->GetHash();
180  }
181 };
182 
183 // extracts a transaction witness-hash from CTxMemPoolEntry or CTransactionRef
185 {
188  {
189  return entry.GetTx().GetWitnessHash();
190  }
191 
193  {
194  return tx->GetWitnessHash();
195  }
196 };
197 
198 
204 {
205 public:
206  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
207  {
208  double a_mod_fee, a_size, b_mod_fee, b_size;
209 
210  GetModFeeAndSize(a, a_mod_fee, a_size);
211  GetModFeeAndSize(b, b_mod_fee, b_size);
212 
213  // Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
214  double f1 = a_mod_fee * b_size;
215  double f2 = a_size * b_mod_fee;
216 
217  if (f1 == f2) {
218  return a.GetTime() >= b.GetTime();
219  }
220  return f1 < f2;
221  }
222 
223  // Return the fee/size we're using for sorting this entry.
224  void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee, double &size) const
225  {
226  // Compare feerate with descendants to feerate of the transaction, and
227  // return the fee/size for the max.
228  double f1 = (double)a.GetModifiedFee() * a.GetSizeWithDescendants();
229  double f2 = (double)a.GetModFeesWithDescendants() * a.GetTxSize();
230 
231  if (f2 > f1) {
232  mod_fee = a.GetModFeesWithDescendants();
233  size = a.GetSizeWithDescendants();
234  } else {
235  mod_fee = a.GetModifiedFee();
236  size = a.GetTxSize();
237  }
238  }
239 };
240 
249 {
250 public:
251  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
252  {
253  double f1 = (double)a.GetFee() * b.GetTxSize();
254  double f2 = (double)b.GetFee() * a.GetTxSize();
255  if (f1 == f2) {
256  return b.GetTx().GetHash() < a.GetTx().GetHash();
257  }
258  return f1 > f2;
259  }
260 };
261 
263 {
264 public:
265  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
266  {
267  return a.GetTime() < b.GetTime();
268  }
269 };
270 
276 {
277 public:
278  template<typename T>
279  bool operator()(const T& a, const T& b) const
280  {
281  double a_mod_fee, a_size, b_mod_fee, b_size;
282 
283  GetModFeeAndSize(a, a_mod_fee, a_size);
284  GetModFeeAndSize(b, b_mod_fee, b_size);
285 
286  // Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
287  double f1 = a_mod_fee * b_size;
288  double f2 = a_size * b_mod_fee;
289 
290  if (f1 == f2) {
291  return a.GetTx().GetHash() < b.GetTx().GetHash();
292  }
293  return f1 > f2;
294  }
295 
296  // Return the fee/size we're using for sorting this entry.
297  template <typename T>
298  void GetModFeeAndSize(const T &a, double &mod_fee, double &size) const
299  {
300  // Compare feerate with ancestors to feerate of the transaction, and
301  // return the fee/size for the min.
302  double f1 = (double)a.GetModifiedFee() * a.GetSizeWithAncestors();
303  double f2 = (double)a.GetModFeesWithAncestors() * a.GetTxSize();
304 
305  if (f1 > f2) {
306  mod_fee = a.GetModFeesWithAncestors();
307  size = a.GetSizeWithAncestors();
308  } else {
309  mod_fee = a.GetModifiedFee();
310  size = a.GetTxSize();
311  }
312  }
313 };
314 
315 // Multi_index tag names
317 struct entry_time {};
318 struct ancestor_score {};
319 struct index_by_wtxid {};
320 
322 
327 {
330 
332  std::chrono::seconds m_time;
333 
336 
338  size_t vsize;
339 
341  int64_t nFeeDelta;
342 };
343 
348  EXPIRY,
349  SIZELIMIT,
350  REORG,
351  BLOCK,
352  CONFLICT,
353  REPLACED,
354 };
355 
430 {
431 protected:
432  const int m_check_ratio;
433  std::atomic<unsigned int> nTransactionsUpdated{0};
435 
436  uint64_t totalTxSize GUARDED_BY(cs);
437  CAmount m_total_fee GUARDED_BY(cs);
438  uint64_t cachedInnerUsage GUARDED_BY(cs);
439 
440  mutable int64_t lastRollingFeeUpdate GUARDED_BY(cs);
441  mutable bool blockSinceLastRollingFeeBump GUARDED_BY(cs);
442  mutable double rollingMinimumFeeRate GUARDED_BY(cs);
443  mutable Epoch m_epoch GUARDED_BY(cs);
444 
445  // In-memory counter for external mempool tracking purposes.
446  // This number is incremented once every time a transaction
447  // is added or removed from the mempool for any reason.
448  mutable uint64_t m_sequence_number GUARDED_BY(cs){1};
449 
451 
452  bool m_is_loaded GUARDED_BY(cs){false};
453 
454 public:
455 
456  static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12; // public only for testing
457 
458  typedef boost::multi_index_container<
460  boost::multi_index::indexed_by<
461  // sorted by txid
462  boost::multi_index::hashed_unique<mempoolentry_txid, SaltedTxidHasher>,
463  // sorted by wtxid
464  boost::multi_index::hashed_unique<
465  boost::multi_index::tag<index_by_wtxid>,
468  >,
469  // sorted by fee rate
470  boost::multi_index::ordered_non_unique<
471  boost::multi_index::tag<descendant_score>,
472  boost::multi_index::identity<CTxMemPoolEntry>,
474  >,
475  // sorted by entry time
476  boost::multi_index::ordered_non_unique<
477  boost::multi_index::tag<entry_time>,
478  boost::multi_index::identity<CTxMemPoolEntry>,
480  >,
481  // sorted by fee rate with ancestors
482  boost::multi_index::ordered_non_unique<
483  boost::multi_index::tag<ancestor_score>,
484  boost::multi_index::identity<CTxMemPoolEntry>,
486  >
487  >
489 
519 
520  using txiter = indexed_transaction_set::nth_index<0>::type::const_iterator;
521  std::vector<std::pair<uint256, txiter>> vTxHashes GUARDED_BY(cs);
522 
523  typedef std::set<txiter, CompareIteratorByHash> setEntries;
524 
526 private:
527  typedef std::map<txiter, setEntries, CompareIteratorByHash> cacheMap;
528 
529 
530  void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs);
531  void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs);
532 
533  std::vector<indexed_transaction_set::const_iterator> GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs);
534 
538  std::set<uint256> m_unbroadcast_txids GUARDED_BY(cs);
539 
540 
549  bool CalculateAncestorsAndCheckLimits(size_t entry_size,
550  size_t entry_count,
551  setEntries& setAncestors,
552  CTxMemPoolEntry::Parents &staged_ancestors,
553  uint64_t limitAncestorCount,
554  uint64_t limitAncestorSize,
555  uint64_t limitDescendantCount,
556  uint64_t limitDescendantSize,
557  std::string &errString) const EXCLUSIVE_LOCKS_REQUIRED(cs);
558 
559 public:
560  indirectmap<COutPoint, const CTransaction*> mapNextTx GUARDED_BY(cs);
561  std::map<uint256, CAmount> mapDeltas GUARDED_BY(cs);
562 
571  explicit CTxMemPool(CBlockPolicyEstimator* estimator = nullptr, int check_ratio = 0);
572 
579  void check(const CCoinsViewCache& active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
580 
581  // addUnchecked must updated state for all ancestors of a given transaction,
582  // to track size/count of descendant transactions. First version of
583  // addUnchecked can be used to have it call CalculateMemPoolAncestors(), and
584  // then invoke the second version.
585  // Note that addUnchecked is ONLY called from ATMP outside of tests
586  // and any other callers may break wallet's in-mempool tracking (due to
587  // lack of CValidationInterface::TransactionAddedToMempool callbacks).
588  void addUnchecked(const CTxMemPoolEntry& entry, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
589  void addUnchecked(const CTxMemPoolEntry& entry, setEntries& setAncestors, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
590 
599  void removeForReorg(CChain& chain, std::function<bool(txiter)> filter_final_and_mature) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
601  void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
602 
603  void clear();
604  void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free
605  bool CompareDepthAndScore(const uint256& hasha, const uint256& hashb, bool wtxid=false);
606  void queryHashes(std::vector<uint256>& vtxid) const;
607  bool isSpent(const COutPoint& outpoint) const;
608  unsigned int GetTransactionsUpdated() const;
609  void AddTransactionsUpdated(unsigned int n);
614  bool HasNoInputsOf(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs);
615 
617  void PrioritiseTransaction(const uint256& hash, const CAmount& nFeeDelta);
618  void ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs);
620 
622  const CTransaction* GetConflictTx(const COutPoint& prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs);
623 
625  std::optional<txiter> GetIter(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);
626 
628  setEntries GetIterSet(const std::set<uint256>& hashes) const EXCLUSIVE_LOCKS_REQUIRED(cs);
629 
637  void RemoveStaged(setEntries& stage, bool updateDescendants, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
638 
649 
660  bool CalculateMemPoolAncestors(const CTxMemPoolEntry& entry, setEntries& setAncestors, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string& errString, bool fSearchForParents = true) const EXCLUSIVE_LOCKS_REQUIRED(cs);
661 
677  bool CheckPackageLimits(const Package& package,
678  uint64_t limitAncestorCount,
679  uint64_t limitAncestorSize,
680  uint64_t limitDescendantCount,
681  uint64_t limitDescendantSize,
682  std::string &errString) const EXCLUSIVE_LOCKS_REQUIRED(cs);
683 
687  void CalculateDescendants(txiter it, setEntries& setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs);
688 
695  CFeeRate GetMinFee(size_t sizelimit) const;
696 
701  void TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpendsRemaining = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
702 
704  int Expire(std::chrono::seconds time) EXCLUSIVE_LOCKS_REQUIRED(cs);
705 
712  void GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) const;
713 
715  bool IsLoaded() const;
716 
718  void SetIsLoaded(bool loaded);
719 
720  unsigned long size() const
721  {
722  LOCK(cs);
723  return mapTx.size();
724  }
725 
727  {
729  return totalTxSize;
730  }
731 
733  {
735  return m_total_fee;
736  }
737 
738  bool exists(const GenTxid& gtxid) const
739  {
740  LOCK(cs);
741  if (gtxid.IsWtxid()) {
742  return (mapTx.get<index_by_wtxid>().count(gtxid.GetHash()) != 0);
743  }
744  return (mapTx.count(gtxid.GetHash()) != 0);
745  }
746 
747  CTransactionRef get(const uint256& hash) const;
749  {
751  return mapTx.project<0>(mapTx.get<index_by_wtxid>().find(wtxid));
752  }
753  TxMempoolInfo info(const GenTxid& gtxid) const;
754  std::vector<TxMempoolInfo> infoAll() const;
755 
756  size_t DynamicMemoryUsage() const;
757 
759  void AddUnbroadcastTx(const uint256& txid)
760  {
761  LOCK(cs);
762  // Sanity check the transaction is in the mempool & insert into
763  // unbroadcast set.
764  if (exists(GenTxid::Txid(txid))) m_unbroadcast_txids.insert(txid);
765  };
766 
768  void RemoveUnbroadcastTx(const uint256& txid, const bool unchecked = false);
769 
771  std::set<uint256> GetUnbroadcastTxs() const
772  {
773  LOCK(cs);
774  return m_unbroadcast_txids;
775  }
776 
779  {
781  return m_unbroadcast_txids.count(txid) != 0;
782  }
783 
786  return m_sequence_number++;
787  }
788 
790  return m_sequence_number;
791  }
792 
793 private:
807  void UpdateForDescendants(txiter updateIt,
808  cacheMap &cachedDescendants,
809  const std::set<uint256> &setExclude) EXCLUSIVE_LOCKS_REQUIRED(cs);
811  void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs);
817  void UpdateForRemoveFromMempool(const setEntries &entriesToRemove, bool updateDescendants) EXCLUSIVE_LOCKS_REQUIRED(cs);
820 
830 public:
839  bool visited(const txiter it) const EXCLUSIVE_LOCKS_REQUIRED(cs, m_epoch)
840  {
841  return m_epoch.visited(it->m_epoch_marker);
842  }
843 
844  bool visited(std::optional<txiter> it) const EXCLUSIVE_LOCKS_REQUIRED(cs, m_epoch)
845  {
846  assert(m_epoch.guarded()); // verify guard even when it==nullopt
847  return !it || visited(*it);
848  }
849 };
850 
865 {
870  std::unordered_map<COutPoint, Coin, SaltedOutpointHasher> m_temp_added;
871 protected:
873 
874 public:
875  CCoinsViewMemPool(CCoinsView* baseIn, const CTxMemPool& mempoolIn);
876  bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
879  void PackageAddTransaction(const CTransactionRef& tx);
880 };
881 
897 // multi_index tag names
898 struct txid_index {};
899 struct insertion_order {};
900 
902  typedef boost::multi_index_container<
904  boost::multi_index::indexed_by<
905  // sorted by txid
906  boost::multi_index::hashed_unique<
907  boost::multi_index::tag<txid_index>,
910  >,
911  // sorted by order in the blockchain
912  boost::multi_index::sequenced<
913  boost::multi_index::tag<insertion_order>
914  >
915  >
917 
918  // It's almost certainly a logic bug if we don't clear out queuedTx before
919  // destruction, as we add to it while disconnecting blocks, and then we
920  // need to re-process remaining transactions to ensure mempool consistency.
921  // For now, assert() that we've emptied out this object on destruction.
922  // This assert() can always be removed if the reorg-processing code were
923  // to be refactored such that this assumption is no longer true (for
924  // instance if there was some other way we cleaned up the mempool after a
925  // reorg, besides draining this object).
927 
929  uint64_t cachedInnerUsage = 0;
930 
931  // Estimate the overhead of queuedTx to be 6 pointers + an allocation, as
932  // no exact formula for boost::multi_index_contained is implemented.
933  size_t DynamicMemoryUsage() const {
934  return memusage::MallocUsage(sizeof(CTransactionRef) + 6 * sizeof(void*)) * queuedTx.size() + cachedInnerUsage;
935  }
936 
938  {
939  queuedTx.insert(tx);
941  }
942 
943  // Remove entries based on txid_index, and update memory usage.
944  void removeForBlock(const std::vector<CTransactionRef>& vtx)
945  {
946  // Short-circuit in the common case of a block being added to the tip
947  if (queuedTx.empty()) {
948  return;
949  }
950  for (auto const &tx : vtx) {
951  auto it = queuedTx.find(tx->GetHash());
952  if (it != queuedTx.end()) {
954  queuedTx.erase(it);
955  }
956  }
957  }
958 
959  // Remove an entry by insertion_order index, and update memory usage.
960  void removeEntry(indexed_disconnected_transactions::index<insertion_order>::type::iterator entry)
961  {
963  queuedTx.get<insertion_order>().erase(entry);
964  }
965 
966  void clear()
967  {
968  cachedInnerUsage = 0;
969  queuedTx.clear();
970  }
971 };
972 
973 #endif // BITCOIN_TXMEMPOOL_H
CTxMemPoolEntry::GetSpendsCoinbase
bool GetSpendsCoinbase() const
Definition: txmempool.h:152
CTxMemPoolEntry::nSigOpCostWithAncestors
int64_t nSigOpCostWithAncestors
Definition: txmempool.h:118
CTxMemPoolEntry::nCountWithDescendants
uint64_t nCountWithDescendants
number of descendant transactions
Definition: txmempool.h:110
CTxMemPool::setEntries
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:523
DisconnectedBlockTransactions::addTransaction
void addTransaction(const CTransactionRef &tx)
Definition: txmempool.h:937
CTxMemPool::AddTransactionsUpdated
void AddTransactionsUpdated(unsigned int n)
Definition: txmempool.cpp:471
CTxMemPool::GetMinFee
CFeeRate GetMinFee(size_t sizelimit) const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
Definition: txmempool.cpp:1096
feerate.h
CTxMemPool::info
TxMempoolInfo info(const GenTxid &gtxid) const
Definition: txmempool.cpp:907
CTxMemPool::removeUnchecked
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:528
CTxMemPool::GetUnbroadcastTxs
std::set< uint256 > GetUnbroadcastTxs() const
Returns transactions in unbroadcast set.
Definition: txmempool.h:771
assert
assert(!tx.IsCoinBase())
CTxMemPoolEntry::feeDelta
int64_t feeDelta
Used for determining the priority of the transaction for mining in a block.
Definition: txmempool.h:104
CTxMemPoolEntry::GetHeight
unsigned int GetHeight() const
Definition: txmempool.h:132
CTxMemPool::CheckPackageLimits
bool CheckPackageLimits(const Package &package, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string &errString) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Calculate all in-mempool ancestors of a set of transactions not already in the mempool and check ance...
Definition: txmempool.cpp:263
CTxMemPoolEntry::Children
std::set< CTxMemPoolEntryRef, CompareIteratorByHash > Children
Definition: txmempool.h:91
CTxMemPoolEntry::nCountWithAncestors
uint64_t nCountWithAncestors
Definition: txmempool.h:115
epochguard.h
CTxMemPoolEntry::GetFee
const CAmount & GetFee() const
Definition: txmempool.h:128
CTxMemPool::ROLLING_FEE_HALFLIFE
static const int ROLLING_FEE_HALFLIFE
Definition: txmempool.h:456
GenTxid
A generic txid reference (txid or wtxid).
Definition: transaction.h:390
TxMempoolInfo::vsize
size_t vsize
Virtual size of the transaction.
Definition: txmempool.h:338
CTxMemPoolEntry::nTime
const int64_t nTime
Local time when entering the mempool.
Definition: txmempool.h:100
txid_index
DisconnectedBlockTransactions.
Definition: txmempool.h:898
CompareTxMemPoolEntryByScore::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:251
CTxMemPoolEntry::lockPoints
LockPoints lockPoints
Track the height and time at which tx was final.
Definition: txmempool.h:105
CTxMemPool::GetSortedDepthAndScore
std::vector< indexed_transaction_set::const_iterator > GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:853
CTxMemPool::visited
bool visited(const txiter it) const EXCLUSIVE_LOCKS_REQUIRED(cs
visited marks a CTxMemPoolEntry as having been traversed during the lifetime of the most recently cre...
sync.h
transaction.h
CTxMemPool::cs_main
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void cs_main
Definition: txmempool.h:588
CTxMemPool::txiter
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
Definition: txmempool.h:520
CTxMemPool::IsLoaded
bool IsLoaded() const
Definition: txmempool.cpp:1205
CTxMemPoolEntry::GetModifiedFee
int64_t GetModifiedFee() const
Definition: txmempool.h:134
CTxMemPool::get_iter_from_wtxid
txiter get_iter_from_wtxid(const uint256 &wtxid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:748
indirectmap
Definition: indirectmap.h:24
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:429
CTxMemPoolEntry::spendsCoinbase
const bool spendsCoinbase
keep track of transactions that spend a coinbase
Definition: txmempool.h:102
LockPoints::time
int64_t time
Definition: txmempool.h:46
DisconnectedBlockTransactions::removeEntry
void removeEntry(indexed_disconnected_transactions::index< insertion_order >::type::iterator entry)
Definition: txmempool.h:960
CompareTxMemPoolEntryByAncestorFee
Definition: txmempool.h:275
CTxMemPool::TrimToSize
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:1128
CTxMemPoolEntry::m_parents
Parents m_parents
Definition: txmempool.h:95
CTxMemPool::ClearPrioritisation
void ClearPrioritisation(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:956
CTxMemPoolEntry::GetTime
std::chrono::seconds GetTime() const
Definition: txmempool.h:131
CTxMemPoolEntry::GetSharedTx
CTransactionRef GetSharedTx() const
Definition: txmempool.h:127
CTxMemPoolEntry::GetMemPoolParentsConst
const Parents & GetMemPoolParentsConst() const
Definition: txmempool.h:159
CTxMemPool::AddUnbroadcastTx
void AddUnbroadcastTx(const uint256 &txid)
Adds a transaction to the unbroadcast set.
Definition: txmempool.h:759
CTxMemPool::SetIsLoaded
void SetIsLoaded(bool loaded)
Sets the current loaded state.
Definition: txmempool.cpp:1211
CTxMemPool::m_epoch
bool m_epoch
Definition: txmempool.h:840
descendant_score
Definition: txmempool.h:316
MemPoolRemovalReason::EXPIRY
@ EXPIRY
Expired from mempool.
CTxMemPoolEntry::GetMemPoolParents
Parents & GetMemPoolParents() const
Definition: txmempool.h:161
AnnotatedMixin< std::recursive_mutex >
CTxMemPool::UpdateChildrenForRemoval
void UpdateChildrenForRemoval(txiter entry) EXCLUSIVE_LOCKS_REQUIRED(cs)
Sever link between specified transaction and direct children.
Definition: txmempool.cpp:366
CTxMemPool::ApplyDelta
void ApplyDelta(const uint256 &hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:946
CTxMemPool::CalculateMemPoolAncestors
bool CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntries &setAncestors, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string &errString, bool fSearchForParents=true) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Try to calculate all in-mempool ancestors of entry.
Definition: txmempool.cpp:298
CTxMemPoolEntry::vTxHashesIdx
size_t vTxHashesIdx
Index in mempool's vTxHashes.
Definition: txmempool.h:164
mempoolentry_wtxid
Definition: txmempool.h:184
CTxMemPoolEntry::nTxWeight
const size_t nTxWeight
... and avoid recomputing tx weight (also used for GetTxSize())
Definition: txmempool.h:98
CTxMemPoolEntry::Parents
std::set< CTxMemPoolEntryRef, CompareIteratorByHash > Parents
Definition: txmempool.h:90
GenTxid::Txid
static GenTxid Txid(const uint256 &hash)
Definition: transaction.h:397
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:386
CCoinsViewMemPool::PackageAddTransaction
void PackageAddTransaction(const CTransactionRef &tx)
Add the coins created by this transaction.
Definition: txmempool.cpp:1018
DisconnectedBlockTransactions::~DisconnectedBlockTransactions
~DisconnectedBlockTransactions()
Definition: txmempool.h:926
CTxMemPool::GetTransactionsUpdated
unsigned int GetTransactionsUpdated() const
Definition: txmempool.cpp:466
CTxMemPool::indexed_transaction_set
boost::multi_index_container< CTxMemPoolEntry, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< mempoolentry_txid, SaltedTxidHasher >, boost::multi_index::hashed_unique< boost::multi_index::tag< index_by_wtxid >, mempoolentry_wtxid, SaltedTxidHasher >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< descendant_score >, boost::multi_index::identity< CTxMemPoolEntry >, CompareTxMemPoolEntryByDescendantScore >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< entry_time >, boost::multi_index::identity< CTxMemPoolEntry >, CompareTxMemPoolEntryByEntryTime >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ancestor_score >, boost::multi_index::identity< CTxMemPoolEntry >, CompareTxMemPoolEntryByAncestorFee > > > indexed_transaction_set
Definition: txmempool.h:488
CTxMemPool::CalculateDescendantMaximum
uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1171
CTxMemPoolEntry::nSizeWithAncestors
uint64_t nSizeWithAncestors
Definition: txmempool.h:116
CCoinsViewMemPool::CCoinsViewMemPool
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn)
Definition: txmempool.cpp:993
CFeeRate
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
TxMempoolInfo::tx
CTransactionRef tx
The transaction itself.
Definition: txmempool.h:329
CTxMemPoolEntry::m_children
Children m_children
Definition: txmempool.h:96
CTxMemPool::queryHashes
void queryHashes(std::vector< uint256 > &vtxid) const
Definition: txmempool.cpp:867
CTxMemPool::UpdateEntryForAncestors
void UpdateEntryForAncestors(txiter it, const setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs)
Set ancestor state for an entry.
Definition: txmempool.cpp:352
CTxMemPoolEntry::nUsageSize
const size_t nUsageSize
... and total memory usage
Definition: txmempool.h:99
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
AssertLockHeld
AssertLockHeld(pool.cs)
CCoinsView
Abstract view on the open txout dataset.
Definition: coins.h:157
CTxMemPoolEntry::nSizeWithDescendants
uint64_t nSizeWithDescendants
... and size
Definition: txmempool.h:111
CTxMemPoolEntry::nModFeesWithDescendants
CAmount nModFeesWithDescendants
... and total fees (all including us)
Definition: txmempool.h:112
CTxMemPool::UpdateForDescendants
void UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendants, const std::set< uint256 > &setExclude) EXCLUSIVE_LOCKS_REQUIRED(cs)
UpdateForDescendants is used by UpdateTransactionsFromBlock to update the descendants for a single tr...
Definition: txmempool.cpp:122
CCoinsViewMemPool::mempool
const CTxMemPool & mempool
Definition: txmempool.h:872
CTxMemPool::GUARDED_BY
bool m_is_loaded GUARDED_BY(cs)
Definition: txmempool.h:452
GenTxid::IsWtxid
bool IsWtxid() const
Definition: transaction.h:399
CTxMemPool::GUARDED_BY
uint64_t totalTxSize GUARDED_BY(cs)
sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discount...
packages.h
CTxMemPool::it
return !it visited * it
Definition: txmempool.h:847
CTxMemPoolEntry::GetSigOpCostWithAncestors
int64_t GetSigOpCostWithAncestors() const
Definition: txmempool.h:157
CTxMemPool::GUARDED_BY
uint64_t m_sequence_number GUARDED_BY(cs)
Definition: txmempool.h:448
insertion_order
Definition: txmempool.h:899
LockPoints::maxInputBlock
CBlockIndex * maxInputBlock
Definition: txmempool.h:50
CTxMemPoolEntry::GetCountWithAncestors
uint64_t GetCountWithAncestors() const
Definition: txmempool.h:154
CompareIteratorByHash
Definition: txmempool.h:58
random.h
TxMempoolInfo::nFeeDelta
int64_t nFeeDelta
The fee delta.
Definition: txmempool.h:341
RecursiveDynamicUsage
static size_t RecursiveDynamicUsage(const CScript &script)
Definition: core_memusage.h:12
CTxMemPoolEntry::GetModFeesWithAncestors
CAmount GetModFeesWithAncestors() const
Definition: txmempool.h:156
entry_time
Definition: txmempool.h:317
CTxMemPool::cs
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition: txmempool.h:517
CTxMemPool::GetAndIncrementSequence
uint64_t GetAndIncrementSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Guards this internal counter for external reporting.
Definition: txmempool.h:785
CTxMemPool::get
CTransactionRef get(const uint256 &hash) const
Definition: txmempool.cpp:898
CCoinsViewMemPool::m_temp_added
std::unordered_map< COutPoint, Coin, SaltedOutpointHasher > m_temp_added
Coins made available by transactions being validated.
Definition: txmempool.h:870
CTxMemPool::GetIterSet
setEntries GetIterSet(const std::set< uint256 > &hashes) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Translate a set of hashes into a set of pool iterators to avoid repeated lookups.
Definition: txmempool.cpp:975
CTxMemPoolEntry::GetSigOpCost
int64_t GetSigOpCost() const
Definition: txmempool.h:133
CompareTxMemPoolEntryByEntryTime
Definition: txmempool.h:262
CTxMemPool::nTransactionsUpdated
std::atomic< unsigned int > nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
Definition: txmempool.h:433
CTxMemPoolEntry::nModFeesWithAncestors
CAmount nModFeesWithAncestors
Definition: txmempool.h:117
Coin
A UTXO entry.
Definition: coins.h:30
Epoch::Marker
Definition: epochguard.h:49
mempoolentry_wtxid::result_type
uint256 result_type
Definition: txmempool.h:186
CTxMemPool::UpdateChild
void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1074
CTxMemPoolEntry::UpdateAncestorState
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps)
Definition: txmempool.cpp:443
CTxMemPool::GetTotalFee
CAmount GetTotalFee() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:732
CTxMemPool::HasNoInputsOf
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:985
CTxMemPool::GetTransactionAncestry
void GetTransactionAncestry(const uint256 &txid, size_t &ancestors, size_t &descendants, size_t *ancestorsize=nullptr, CAmount *ancestorfees=nullptr) const
Calculate the ancestor and descendant count for the given transaction.
Definition: txmempool.cpp:1193
SaltedTxidHasher
Definition: hasher.h:12
CompareTxMemPoolEntryByDescendantScore::GetModFeeAndSize
void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee, double &size) const
Definition: txmempool.h:224
CTxMemPoolEntry::UpdateDescendantState
void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount)
Definition: txmempool.cpp:434
CBlockPolicyEstimator
Definition: fees.h:131
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
CTxMemPool::GetSequence
uint64_t GetSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:789
DisconnectedBlockTransactions::indexed_disconnected_transactions
boost::multi_index_container< CTransactionRef, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::tag< txid_index >, mempoolentry_txid, SaltedTxidHasher >, boost::multi_index::sequenced< boost::multi_index::tag< insertion_order > > > > indexed_disconnected_transactions
Definition: txmempool.h:916
LockPoints::height
int height
Definition: txmempool.h:45
MemPoolRemovalReason::SIZELIMIT
@ SIZELIMIT
Removed in size limiting.
CTxMemPool::removeConflicts
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:646
CTxMemPool::CalculateAncestorsAndCheckLimits
bool CalculateAncestorsAndCheckLimits(size_t entry_size, size_t entry_count, setEntries &setAncestors, CTxMemPoolEntry::Parents &staged_ancestors, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string &errString) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Helper function to calculate all in-mempool ancestors of staged_ancestors and apply ancestor and desc...
Definition: txmempool.cpp:214
CTxMemPool::m_check_ratio
const int m_check_ratio
Value n means that 1 times in n we check.
Definition: txmempool.h:432
CTxMemPool::UpdateParent
void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1085
CTxMemPool::RemoveUnbroadcastTx
void RemoveUnbroadcastTx(const uint256 &txid, const bool unchecked=false)
Removes a transaction from the unbroadcast set.
Definition: txmempool.cpp:1031
CTxMemPool::UpdateTransactionsFromBlock
void UpdateTransactionsFromBlock(const std::vector< uint256 > &vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs
When adding transactions from a disconnected block back to the mempool, new mempool entries may have ...
Definition: txmempool.cpp:169
uint256
256-bit opaque blob.
Definition: uint256.h:124
CTxMemPoolEntry::nFee
const CAmount nFee
Cached to avoid expensive parent-transaction lookups.
Definition: txmempool.h:97
MemPoolRemovalReason::REPLACED
@ REPLACED
Removed for replacement.
CompareIteratorByHash::operator()
bool operator()(const T &a, const T &b) const
Definition: txmempool.h:67
CChainState
CChainState stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:443
CompareTxMemPoolEntryByScore
Definition: txmempool.h:248
CTxMemPoolEntry::UpdateFeeDelta
void UpdateFeeDelta(int64_t feeDelta)
Definition: txmempool.cpp:102
CCoinsViewMemPool::GetCoin
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: txmempool.cpp:995
coins.h
CompareIteratorByHash::operator()
bool operator()(const std::reference_wrapper< T > &a, const std::reference_wrapper< T > &b) const
Definition: txmempool.h:62
DisconnectedBlockTransactions::clear
void clear()
Definition: txmempool.h:966
CTxMemPool::GetIter
std::optional< txiter > GetIter(const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given hash, if found.
Definition: txmempool.cpp:968
TestLockPointValidity
bool TestLockPointValidity(CChain &active_chain, const LockPoints &lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Test whether the LockPoints height and time are still valid on the current chain.
Definition: txmempool.cpp:67
CTxMemPoolEntry::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.h:135
ancestor_score
Definition: txmempool.h:318
DisconnectedBlockTransactions::removeForBlock
void removeForBlock(const std::vector< CTransactionRef > &vtx)
Definition: txmempool.h:944
mempoolentry_txid::operator()
result_type operator()(const CTxMemPoolEntry &entry) const
Definition: txmempool.h:172
hasher.h
index_by_wtxid
Definition: txmempool.h:319
CTxMemPool::PrioritiseTransaction
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
Definition: txmempool.cpp:916
CTxMemPool::UpdateForRemoveFromMempool
void UpdateForRemoveFromMempool(const setEntries &entriesToRemove, bool updateDescendants) EXCLUSIVE_LOCKS_REQUIRED(cs)
For each transaction being removed, update ancestors and any direct children.
Definition: txmempool.cpp:374
CTxMemPoolEntry::GetMemPoolChildrenConst
const Children & GetMemPoolChildrenConst() const
Definition: txmempool.h:160
CTxMemPool::Expire
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:1048
CTxMemPoolEntry::tx
const CTransactionRef tx
Definition: txmempool.h:94
CTxMemPool::LOCKS_EXCLUDED
void cs_main LOCKS_EXCLUDED(m_epoch)
CTxMemPool::exists
bool exists(const GenTxid &gtxid) const
Definition: txmempool.h:738
DisconnectedBlockTransactions
Definition: txmempool.h:901
CTxMemPool::UpdateAncestorsOf
void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs)
Update ancestors of hash to add/remove it as a descendant transaction.
Definition: txmempool.cpp:337
CChain
An in-memory indexed chain of blocks.
Definition: chain.h:417
GenTxid::GetHash
const uint256 & GetHash() const
Definition: transaction.h:400
CTxMemPool::IsUnbroadcastTx
bool IsUnbroadcastTx(const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns whether a txid is in the unbroadcast set.
Definition: txmempool.h:778
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:213
CCoinsViewBacked
CCoinsView backed by another CCoinsView.
Definition: coins.h:194
CTxMemPoolEntry::GetLockPoints
const LockPoints & GetLockPoints() const
Definition: txmempool.h:136
CTxMemPool::addUnchecked
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void addUnchecked(const CTxMemPoolEntry &entry, bool validFeeEstimate=true) 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:588
CompareTxMemPoolEntryByDescendantScore
Definition: txmempool.h:203
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
indirectmap.h
CompareTxMemPoolEntryByAncestorFee::GetModFeeAndSize
void GetModFeeAndSize(const T &a, double &mod_fee, double &size) const
Definition: txmempool.h:298
DisconnectedBlockTransactions::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.h:933
CTxMemPoolEntry
Definition: txmempool.h:85
LOCK
#define LOCK(cs)
Definition: sync.h:226
MemPoolRemovalReason
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:347
DisconnectedBlockTransactions::queuedTx
indexed_disconnected_transactions queuedTx
Definition: txmempool.h:928
CTxMemPool::infoAll
std::vector< TxMempoolInfo > infoAll() const
Definition: txmempool.cpp:884
CTxMemPool::GetConflictTx
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:962
std
Definition: setup_common.h:33
CompareTxMemPoolEntryByAncestorFee::operator()
bool operator()(const T &a, const T &b) const
Definition: txmempool.h:279
LockPoints
Definition: txmempool.h:41
mempoolentry_txid
Definition: txmempool.h:169
ByteUnit::T
@ T
CTxMemPool::trackPackageRemoved
void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1120
CTxMemPool::RemoveStaged
void RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove a set of transactions from the mempool.
Definition: txmempool.cpp:1040
CCoinsViewMemPool
CCoinsView that brings transactions from a mempool into view.
Definition: txmempool.h:864
CTxMemPool::size
unsigned long size() const
Definition: txmempool.h:720
CTxMemPool::removeForReorg
void removeForReorg(CChain &chain, std::function< bool(txiter)> filter_final_and_mature) EXCLUSIVE_LOCKS_REQUIRED(cs
After reorg, filter the entries that would no longer be valid in the next block, and update the entri...
Definition: txmempool.cpp:626
TxMempoolInfo
Information about a mempool transaction.
Definition: txmempool.h:326
CTxMemPoolEntry::UpdateLockPoints
void UpdateLockPoints(const LockPoints &lp)
Definition: txmempool.cpp:109
memusage::MallocUsage
static size_t MallocUsage(size_t alloc)
Compute the total memory used by allocating alloc bytes.
Definition: memusage.h:50
CompareTxMemPoolEntryByDescendantScore::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:206
CTxMemPool::CompareDepthAndScore
bool CompareDepthAndScore(const uint256 &hasha, const uint256 &hashb, bool wtxid=false)
Definition: txmempool.cpp:822
Package
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition: packages.h:32
CTxMemPoolEntry::GetModFeesWithDescendants
CAmount GetModFeesWithDescendants() const
Definition: txmempool.h:150
MEMPOOL_HEIGHT
static const uint32_t MEMPOOL_HEIGHT
Fake height value used in Coin to signify they are only in the memory pool (since 0....
Definition: txmempool.h:39
CTransaction::GetWitnessHash
const uint256 & GetWitnessHash() const
Definition: transaction.h:303
CTxMemPool::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.cpp:1025
CTxMemPoolEntry::GetTxSize
size_t GetTxSize() const
Definition: txmempool.cpp:114
CTxMemPoolEntry::GetTxWeight
size_t GetTxWeight() const
Definition: txmempool.h:130
CTransaction::GetHash
const uint256 & GetHash() const
Definition: transaction.h:302
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
lp
LockPoints lp
Definition: mempool_eviction.cpp:17
CTxMemPoolEntry::GetMemPoolChildren
Children & GetMemPoolChildren() const
Definition: txmempool.h:162
MemPoolRemovalReason::BLOCK
@ BLOCK
Removed for block.
mempoolentry_txid::result_type
uint256 result_type
Definition: txmempool.h:171
TxMempoolInfo::m_time
std::chrono::seconds m_time
Time the transaction entered the mempool.
Definition: txmempool.h:332
CTxMemPool::GetTotalTxSize
uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:726
CTxMemPoolEntry::GetSizeWithAncestors
uint64_t GetSizeWithAncestors() const
Definition: txmempool.h:155
TxMempoolInfo::fee
CAmount fee
Fee of the transaction.
Definition: txmempool.h:335
CTxMemPoolEntry::GetCountWithDescendants
uint64_t GetCountWithDescendants() const
Definition: txmempool.h:148
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:148
CTxMemPoolEntry::entryHeight
const unsigned int entryHeight
Chain height when entering the mempool.
Definition: txmempool.h:101
CTxMemPool::cacheMap
std::map< txiter, setEntries, CompareIteratorByHash > cacheMap
Definition: txmempool.h:527
CTxMemPool::isSpent
bool isSpent(const COutPoint &outpoint) const
Definition: txmempool.cpp:460
amount.h
CTxMemPoolEntry::sigOpCost
const int64_t sigOpCost
Total sigop cost.
Definition: txmempool.h:103
CTxMemPoolEntry::CTxMemPoolEntryRef
std::reference_wrapper< const CTxMemPoolEntry > CTxMemPoolEntryRef
Definition: txmempool.h:88
CTxMemPool::clear
void clear()
Definition: txmempool.cpp:708
CompareTxMemPoolEntryByEntryTime::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:265
CTxMemPool::_clear
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:695
mempoolentry_wtxid::operator()
result_type operator()(const CTxMemPoolEntry &entry) const
Definition: txmempool.h:187
CTxMemPool::minerPolicyEstimator
CBlockPolicyEstimator *const minerPolicyEstimator
Definition: txmempool.h:434
CTxMemPoolEntry::GetSizeWithDescendants
uint64_t GetSizeWithDescendants() const
Definition: txmempool.h:149
MemPoolRemovalReason::CONFLICT
@ CONFLICT
Removed for conflict with in-block transaction.
MemPoolRemovalReason::REORG
@ REORG
Removed for reorganization.
DisconnectedBlockTransactions::cachedInnerUsage
uint64_t cachedInnerUsage
Definition: txmempool.h:929
Epoch
Epoch: RAII-style guard for using epoch-based graph traversal algorithms.
Definition: epochguard.h:33
CTxMemPoolEntry::CTxMemPoolEntry
CTxMemPoolEntry(const CTransactionRef &tx, CAmount fee, int64_t time, unsigned int entry_height, bool spends_coinbase, int64_t sigops_cost, LockPoints lp)
Definition: txmempool.cpp:84
CTxMemPoolEntry::m_epoch_marker
Epoch::Marker m_epoch_marker
epoch when last touched, useful for graph algorithms
Definition: txmempool.h:165
CTxMemPool::removeForBlock
void removeForBlock(const std::vector< CTransactionRef > &vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs)
Called when a block is connected.
Definition: txmempool.cpp:666
CTxMemPool::removeRecursive
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:596
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:138
CTxMemPool::CalculateDescendants
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of hash.
Definition: txmempool.cpp:572
CTxMemPoolEntry::GetTx
const CTransaction & GetTx() const
Definition: txmempool.h:126