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-2020 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 <amount.h>
18 #include <coins.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_container.hpp>
29 #include <boost/multi_index/hashed_index.hpp>
30 #include <boost/multi_index/ordered_index.hpp>
31 #include <boost/multi_index/sequenced_index.hpp>
32 
33 class CBlockIndex;
34 class CChainState;
35 extern RecursiveMutex cs_main;
36 
38 static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
39 
40 struct LockPoints {
41  // Will be set to the blockchain height and median time past
42  // values that would be necessary to satisfy all relative locktime
43  // constraints (BIP68) of this tx given our view of block chain history
44  int height{0};
45  int64_t time{0};
46  // As long as the current chain descends from the highest height block
47  // containing one of the inputs used in the calculation, then the cached
48  // values are still valid even after a reorg.
50 };
51 
53  // SFINAE for T where T is either a pointer type (e.g., a txiter) or a reference_wrapper<T>
54  // (e.g. a wrapped CTxMemPoolEntry&)
55  template <typename T>
56  bool operator()(const std::reference_wrapper<T>& a, const std::reference_wrapper<T>& b) const
57  {
58  return a.get().GetTx().GetHash() < b.get().GetTx().GetHash();
59  }
60  template <typename T>
61  bool operator()(const T& a, const T& b) const
62  {
63  return a->GetTx().GetHash() < b->GetTx().GetHash();
64  }
65 };
66 
80 {
81 public:
82  typedef std::reference_wrapper<const CTxMemPoolEntry> CTxMemPoolEntryRef;
83  // two aliases, should the types ever diverge
84  typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> Parents;
85  typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> Children;
86 
87 private:
89  mutable Parents m_parents;
91  const CAmount nFee;
92  const size_t nTxWeight;
93  const size_t nUsageSize;
94  const int64_t nTime;
95  const unsigned int entryHeight;
96  const bool spendsCoinbase;
97  const int64_t sigOpCost;
98  int64_t feeDelta{0};
100 
101  // Information about descendants of this transaction that are in the
102  // mempool; if we remove this transaction we must remove all of these
103  // descendants as well.
104  uint64_t nCountWithDescendants{1};
107 
108  // Analogous statistics for ancestor transactions
109  uint64_t nCountWithAncestors{1};
113 
114 public:
116  int64_t time, unsigned int entry_height,
117  bool spends_coinbase,
118  int64_t sigops_cost, LockPoints lp);
119 
120  const CTransaction& GetTx() const { return *this->tx; }
121  CTransactionRef GetSharedTx() const { return this->tx; }
122  const CAmount& GetFee() const { return nFee; }
123  size_t GetTxSize() const;
124  size_t GetTxWeight() const { return nTxWeight; }
125  std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
126  unsigned int GetHeight() const { return entryHeight; }
127  int64_t GetSigOpCost() const { return sigOpCost; }
128  int64_t GetModifiedFee() const { return nFee + feeDelta; }
129  size_t DynamicMemoryUsage() const { return nUsageSize; }
130  const LockPoints& GetLockPoints() const { return lockPoints; }
131 
132  // Adjusts the descendant state.
133  void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount);
134  // Adjusts the ancestor state
135  void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps);
136  // Updates the fee delta used for mining priority score, and the
137  // modified fees with descendants.
138  void UpdateFeeDelta(int64_t feeDelta);
139  // Update the LockPoints after a reorg
140  void UpdateLockPoints(const LockPoints& lp);
141 
142  uint64_t GetCountWithDescendants() const { return nCountWithDescendants; }
143  uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
145 
146  bool GetSpendsCoinbase() const { return spendsCoinbase; }
147 
148  uint64_t GetCountWithAncestors() const { return nCountWithAncestors; }
149  uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
152 
153  const Parents& GetMemPoolParentsConst() const { return m_parents; }
154  const Children& GetMemPoolChildrenConst() const { return m_children; }
155  Parents& GetMemPoolParents() const { return m_parents; }
157 
158  mutable size_t vTxHashesIdx;
160 };
161 
162 // Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index.
164 {
165  update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) :
166  modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount)
167  {}
168 
171 
172  private:
173  int64_t modifySize;
175  int64_t modifyCount;
176 };
177 
179 {
180  update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost) :
181  modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost)
182  {}
183 
186 
187  private:
188  int64_t modifySize;
190  int64_t modifyCount;
192 };
193 
195 {
196  explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
197 
199 
200 private:
201  int64_t feeDelta;
202 };
203 
205 {
206  explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
207 
209 
210 private:
211  const LockPoints& lp;
212 };
213 
214 // extracts a transaction hash from CTxMemPoolEntry or CTransactionRef
216 {
219  {
220  return entry.GetTx().GetHash();
221  }
222 
224  {
225  return tx->GetHash();
226  }
227 };
228 
229 // extracts a transaction witness-hash from CTxMemPoolEntry or CTransactionRef
231 {
234  {
235  return entry.GetTx().GetWitnessHash();
236  }
237 
239  {
240  return tx->GetWitnessHash();
241  }
242 };
243 
244 
250 {
251 public:
252  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
253  {
254  double a_mod_fee, a_size, b_mod_fee, b_size;
255 
256  GetModFeeAndSize(a, a_mod_fee, a_size);
257  GetModFeeAndSize(b, b_mod_fee, b_size);
258 
259  // Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
260  double f1 = a_mod_fee * b_size;
261  double f2 = a_size * b_mod_fee;
262 
263  if (f1 == f2) {
264  return a.GetTime() >= b.GetTime();
265  }
266  return f1 < f2;
267  }
268 
269  // Return the fee/size we're using for sorting this entry.
270  void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee, double &size) const
271  {
272  // Compare feerate with descendants to feerate of the transaction, and
273  // return the fee/size for the max.
274  double f1 = (double)a.GetModifiedFee() * a.GetSizeWithDescendants();
275  double f2 = (double)a.GetModFeesWithDescendants() * a.GetTxSize();
276 
277  if (f2 > f1) {
278  mod_fee = a.GetModFeesWithDescendants();
279  size = a.GetSizeWithDescendants();
280  } else {
281  mod_fee = a.GetModifiedFee();
282  size = a.GetTxSize();
283  }
284  }
285 };
286 
295 {
296 public:
297  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
298  {
299  double f1 = (double)a.GetFee() * b.GetTxSize();
300  double f2 = (double)b.GetFee() * a.GetTxSize();
301  if (f1 == f2) {
302  return b.GetTx().GetHash() < a.GetTx().GetHash();
303  }
304  return f1 > f2;
305  }
306 };
307 
309 {
310 public:
311  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
312  {
313  return a.GetTime() < b.GetTime();
314  }
315 };
316 
322 {
323 public:
324  template<typename T>
325  bool operator()(const T& a, const T& b) const
326  {
327  double a_mod_fee, a_size, b_mod_fee, b_size;
328 
329  GetModFeeAndSize(a, a_mod_fee, a_size);
330  GetModFeeAndSize(b, b_mod_fee, b_size);
331 
332  // Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
333  double f1 = a_mod_fee * b_size;
334  double f2 = a_size * b_mod_fee;
335 
336  if (f1 == f2) {
337  return a.GetTx().GetHash() < b.GetTx().GetHash();
338  }
339  return f1 > f2;
340  }
341 
342  // Return the fee/size we're using for sorting this entry.
343  template <typename T>
344  void GetModFeeAndSize(const T &a, double &mod_fee, double &size) const
345  {
346  // Compare feerate with ancestors to feerate of the transaction, and
347  // return the fee/size for the min.
348  double f1 = (double)a.GetModifiedFee() * a.GetSizeWithAncestors();
349  double f2 = (double)a.GetModFeesWithAncestors() * a.GetTxSize();
350 
351  if (f1 > f2) {
352  mod_fee = a.GetModFeesWithAncestors();
353  size = a.GetSizeWithAncestors();
354  } else {
355  mod_fee = a.GetModifiedFee();
356  size = a.GetTxSize();
357  }
358  }
359 };
360 
361 // Multi_index tag names
363 struct entry_time {};
364 struct ancestor_score {};
365 struct index_by_wtxid {};
366 
368 
373 {
376 
378  std::chrono::seconds m_time;
379 
382 
384  size_t vsize;
385 
387  int64_t nFeeDelta;
388 };
389 
394  EXPIRY,
395  SIZELIMIT,
396  REORG,
397  BLOCK,
398  CONFLICT,
399  REPLACED,
400 };
401 
476 {
477 protected:
478  const int m_check_ratio;
479  std::atomic<unsigned int> nTransactionsUpdated{0};
481 
482  uint64_t totalTxSize GUARDED_BY(cs);
483  CAmount m_total_fee GUARDED_BY(cs);
484  uint64_t cachedInnerUsage GUARDED_BY(cs);
485 
486  mutable int64_t lastRollingFeeUpdate GUARDED_BY(cs);
487  mutable bool blockSinceLastRollingFeeBump GUARDED_BY(cs);
488  mutable double rollingMinimumFeeRate GUARDED_BY(cs);
489  mutable Epoch m_epoch GUARDED_BY(cs);
490 
491  // In-memory counter for external mempool tracking purposes.
492  // This number is incremented once every time a transaction
493  // is added or removed from the mempool for any reason.
494  mutable uint64_t m_sequence_number GUARDED_BY(cs){1};
495 
497 
498  bool m_is_loaded GUARDED_BY(cs){false};
499 
500 public:
501 
502  static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12; // public only for testing
503 
504  typedef boost::multi_index_container<
506  boost::multi_index::indexed_by<
507  // sorted by txid
508  boost::multi_index::hashed_unique<mempoolentry_txid, SaltedTxidHasher>,
509  // sorted by wtxid
510  boost::multi_index::hashed_unique<
511  boost::multi_index::tag<index_by_wtxid>,
514  >,
515  // sorted by fee rate
516  boost::multi_index::ordered_non_unique<
517  boost::multi_index::tag<descendant_score>,
518  boost::multi_index::identity<CTxMemPoolEntry>,
520  >,
521  // sorted by entry time
522  boost::multi_index::ordered_non_unique<
523  boost::multi_index::tag<entry_time>,
524  boost::multi_index::identity<CTxMemPoolEntry>,
526  >,
527  // sorted by fee rate with ancestors
528  boost::multi_index::ordered_non_unique<
529  boost::multi_index::tag<ancestor_score>,
530  boost::multi_index::identity<CTxMemPoolEntry>,
532  >
533  >
535 
565 
566  using txiter = indexed_transaction_set::nth_index<0>::type::const_iterator;
567  std::vector<std::pair<uint256, txiter>> vTxHashes GUARDED_BY(cs);
568 
569  typedef std::set<txiter, CompareIteratorByHash> setEntries;
570 
572 private:
573  typedef std::map<txiter, setEntries, CompareIteratorByHash> cacheMap;
574 
575 
576  void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs);
577  void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs);
578 
579  std::vector<indexed_transaction_set::const_iterator> GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs);
580 
584  std::set<uint256> m_unbroadcast_txids GUARDED_BY(cs);
585 
586 
595  bool CalculateAncestorsAndCheckLimits(size_t entry_size,
596  size_t entry_count,
597  setEntries& setAncestors,
598  CTxMemPoolEntry::Parents &staged_ancestors,
599  uint64_t limitAncestorCount,
600  uint64_t limitAncestorSize,
601  uint64_t limitDescendantCount,
602  uint64_t limitDescendantSize,
603  std::string &errString) const EXCLUSIVE_LOCKS_REQUIRED(cs);
604 
605 public:
606  indirectmap<COutPoint, const CTransaction*> mapNextTx GUARDED_BY(cs);
607  std::map<uint256, CAmount> mapDeltas GUARDED_BY(cs);
608 
617  explicit CTxMemPool(CBlockPolicyEstimator* estimator = nullptr, int check_ratio = 0);
618 
625  void check(CChainState& active_chainstate) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
626 
627  // addUnchecked must updated state for all ancestors of a given transaction,
628  // to track size/count of descendant transactions. First version of
629  // addUnchecked can be used to have it call CalculateMemPoolAncestors(), and
630  // then invoke the second version.
631  // Note that addUnchecked is ONLY called from ATMP outside of tests
632  // and any other callers may break wallet's in-mempool tracking (due to
633  // lack of CValidationInterface::TransactionAddedToMempool callbacks).
634  void addUnchecked(const CTxMemPoolEntry& entry, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
635  void addUnchecked(const CTxMemPoolEntry& entry, setEntries& setAncestors, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
636 
638  void removeForReorg(CChainState& active_chainstate, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
640  void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
641 
642  void clear();
643  void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free
644  bool CompareDepthAndScore(const uint256& hasha, const uint256& hashb, bool wtxid=false);
645  void queryHashes(std::vector<uint256>& vtxid) const;
646  bool isSpent(const COutPoint& outpoint) const;
647  unsigned int GetTransactionsUpdated() const;
648  void AddTransactionsUpdated(unsigned int n);
653  bool HasNoInputsOf(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs);
654 
656  void PrioritiseTransaction(const uint256& hash, const CAmount& nFeeDelta);
657  void ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs);
659 
661  const CTransaction* GetConflictTx(const COutPoint& prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs);
662 
664  std::optional<txiter> GetIter(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);
665 
667  setEntries GetIterSet(const std::set<uint256>& hashes) const EXCLUSIVE_LOCKS_REQUIRED(cs);
668 
676  void RemoveStaged(setEntries& stage, bool updateDescendants, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
677 
687  void UpdateTransactionsFromBlock(const std::vector<uint256>& vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main) LOCKS_EXCLUDED(m_epoch);
688 
699  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);
700 
716  bool CheckPackageLimits(const Package& package,
717  uint64_t limitAncestorCount,
718  uint64_t limitAncestorSize,
719  uint64_t limitDescendantCount,
720  uint64_t limitDescendantSize,
721  std::string &errString) const EXCLUSIVE_LOCKS_REQUIRED(cs);
722 
726  void CalculateDescendants(txiter it, setEntries& setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs);
727 
734  CFeeRate GetMinFee(size_t sizelimit) const;
735 
740  void TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpendsRemaining = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);
741 
743  int Expire(std::chrono::seconds time) EXCLUSIVE_LOCKS_REQUIRED(cs);
744 
751  void GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) const;
752 
754  bool IsLoaded() const;
755 
757  void SetIsLoaded(bool loaded);
758 
759  unsigned long size() const
760  {
761  LOCK(cs);
762  return mapTx.size();
763  }
764 
766  {
768  return totalTxSize;
769  }
770 
772  {
774  return m_total_fee;
775  }
776 
777  bool exists(const GenTxid& gtxid) const
778  {
779  LOCK(cs);
780  if (gtxid.IsWtxid()) {
781  return (mapTx.get<index_by_wtxid>().count(gtxid.GetHash()) != 0);
782  }
783  return (mapTx.count(gtxid.GetHash()) != 0);
784  }
785  bool exists(const uint256& txid) const { return exists(GenTxid{false, txid}); }
786 
787  CTransactionRef get(const uint256& hash) const;
789  {
791  return mapTx.project<0>(mapTx.get<index_by_wtxid>().find(wtxid));
792  }
793  TxMempoolInfo info(const uint256& hash) const;
794  TxMempoolInfo info(const GenTxid& gtxid) const;
795  std::vector<TxMempoolInfo> infoAll() const;
796 
797  size_t DynamicMemoryUsage() const;
798 
800  void AddUnbroadcastTx(const uint256& txid)
801  {
802  LOCK(cs);
803  // Sanity check the transaction is in the mempool & insert into
804  // unbroadcast set.
805  if (exists(txid)) m_unbroadcast_txids.insert(txid);
806  };
807 
809  void RemoveUnbroadcastTx(const uint256& txid, const bool unchecked = false);
810 
812  std::set<uint256> GetUnbroadcastTxs() const
813  {
814  LOCK(cs);
815  return m_unbroadcast_txids;
816  }
817 
820  {
822  return m_unbroadcast_txids.count(txid) != 0;
823  }
824 
827  return m_sequence_number++;
828  }
829 
831  return m_sequence_number;
832  }
833 
834 private:
848  void UpdateForDescendants(txiter updateIt,
849  cacheMap &cachedDescendants,
850  const std::set<uint256> &setExclude) EXCLUSIVE_LOCKS_REQUIRED(cs);
852  void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs);
858  void UpdateForRemoveFromMempool(const setEntries &entriesToRemove, bool updateDescendants) EXCLUSIVE_LOCKS_REQUIRED(cs);
861 
871 public:
880  bool visited(const txiter it) const EXCLUSIVE_LOCKS_REQUIRED(cs, m_epoch)
881  {
882  return m_epoch.visited(it->m_epoch_marker);
883  }
884 
885  bool visited(std::optional<txiter> it) const EXCLUSIVE_LOCKS_REQUIRED(cs, m_epoch)
886  {
887  assert(m_epoch.guarded()); // verify guard even when it==nullopt
888  return !it || visited(*it);
889  }
890 };
891 
906 {
911  std::unordered_map<COutPoint, Coin, SaltedOutpointHasher> m_temp_added;
912 protected:
914 
915 public:
916  CCoinsViewMemPool(CCoinsView* baseIn, const CTxMemPool& mempoolIn);
917  bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
920  void PackageAddTransaction(const CTransactionRef& tx);
921 };
922 
938 // multi_index tag names
939 struct txid_index {};
940 struct insertion_order {};
941 
943  typedef boost::multi_index_container<
945  boost::multi_index::indexed_by<
946  // sorted by txid
947  boost::multi_index::hashed_unique<
948  boost::multi_index::tag<txid_index>,
951  >,
952  // sorted by order in the blockchain
953  boost::multi_index::sequenced<
954  boost::multi_index::tag<insertion_order>
955  >
956  >
958 
959  // It's almost certainly a logic bug if we don't clear out queuedTx before
960  // destruction, as we add to it while disconnecting blocks, and then we
961  // need to re-process remaining transactions to ensure mempool consistency.
962  // For now, assert() that we've emptied out this object on destruction.
963  // This assert() can always be removed if the reorg-processing code were
964  // to be refactored such that this assumption is no longer true (for
965  // instance if there was some other way we cleaned up the mempool after a
966  // reorg, besides draining this object).
968 
970  uint64_t cachedInnerUsage = 0;
971 
972  // Estimate the overhead of queuedTx to be 6 pointers + an allocation, as
973  // no exact formula for boost::multi_index_contained is implemented.
974  size_t DynamicMemoryUsage() const {
975  return memusage::MallocUsage(sizeof(CTransactionRef) + 6 * sizeof(void*)) * queuedTx.size() + cachedInnerUsage;
976  }
977 
979  {
980  queuedTx.insert(tx);
982  }
983 
984  // Remove entries based on txid_index, and update memory usage.
985  void removeForBlock(const std::vector<CTransactionRef>& vtx)
986  {
987  // Short-circuit in the common case of a block being added to the tip
988  if (queuedTx.empty()) {
989  return;
990  }
991  for (auto const &tx : vtx) {
992  auto it = queuedTx.find(tx->GetHash());
993  if (it != queuedTx.end()) {
995  queuedTx.erase(it);
996  }
997  }
998  }
999 
1000  // Remove an entry by insertion_order index, and update memory usage.
1001  void removeEntry(indexed_disconnected_transactions::index<insertion_order>::type::iterator entry)
1002  {
1004  queuedTx.get<insertion_order>().erase(entry);
1005  }
1006 
1007  void clear()
1008  {
1009  cachedInnerUsage = 0;
1010  queuedTx.clear();
1011  }
1012 };
1013 
1014 #endif // BITCOIN_TXMEMPOOL_H
CTxMemPoolEntry::GetSpendsCoinbase
bool GetSpendsCoinbase() const
Definition: txmempool.h:146
CTxMemPoolEntry::nSigOpCostWithAncestors
int64_t nSigOpCostWithAncestors
Definition: txmempool.h:112
CTxMemPoolEntry::nCountWithDescendants
uint64_t nCountWithDescendants
number of descendant transactions
Definition: txmempool.h:104
CTxMemPool::setEntries
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:569
DisconnectedBlockTransactions::addTransaction
void addTransaction(const CTransactionRef &tx)
Definition: txmempool.h:978
CTxMemPool::AddTransactionsUpdated
void AddTransactionsUpdated(unsigned int n)
Definition: txmempool.cpp:411
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:1080
feerate.h
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:468
CTxMemPool::GetUnbroadcastTxs
std::set< uint256 > GetUnbroadcastTxs() const
Returns transactions in unbroadcast set.
Definition: txmempool.h:812
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:98
update_fee_delta
Definition: txmempool.h:194
CTxMemPoolEntry::GetHeight
unsigned int GetHeight() const
Definition: txmempool.h:126
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:203
CTxMemPoolEntry::Children
std::set< CTxMemPoolEntryRef, CompareIteratorByHash > Children
Definition: txmempool.h:85
CTxMemPoolEntry::nCountWithAncestors
uint64_t nCountWithAncestors
Definition: txmempool.h:109
epochguard.h
CTxMemPoolEntry::GetFee
const CAmount & GetFee() const
Definition: txmempool.h:122
CTxMemPool::ROLLING_FEE_HALFLIFE
static const int ROLLING_FEE_HALFLIFE
Definition: txmempool.h:502
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:384
CTxMemPoolEntry::nTime
const int64_t nTime
Local time when entering the mempool.
Definition: txmempool.h:94
flags
int flags
Definition: bitcoin-tx.cpp:513
txid_index
DisconnectedBlockTransactions.
Definition: txmempool.h:939
CompareTxMemPoolEntryByScore::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:297
CTxMemPoolEntry::lockPoints
LockPoints lockPoints
Track the height and time at which tx was final.
Definition: txmempool.h:99
update_lock_points
Definition: txmempool.h:204
CTxMemPool::GetSortedDepthAndScore
std::vector< indexed_transaction_set::const_iterator > GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:835
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
update_descendant_state::modifyCount
int64_t modifyCount
Definition: txmempool.h:175
transaction.h
CTxMemPool::cs_main
void check(CChainState &active_chainstate) const EXCLUSIVE_LOCKS_REQUIRED(void cs_main
Definition: txmempool.h:634
CTxMemPool::txiter
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
Definition: txmempool.h:566
CTxMemPool::IsLoaded
bool IsLoaded() const
Definition: txmempool.cpp:1189
CTxMemPoolEntry::GetModifiedFee
int64_t GetModifiedFee() const
Definition: txmempool.h:128
CTxMemPool::get_iter_from_wtxid
txiter get_iter_from_wtxid(const uint256 &wtxid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:788
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:475
CTxMemPoolEntry::spendsCoinbase
const bool spendsCoinbase
keep track of transactions that spend a coinbase
Definition: txmempool.h:96
LockPoints::time
int64_t time
Definition: txmempool.h:45
DisconnectedBlockTransactions::removeEntry
void removeEntry(indexed_disconnected_transactions::index< insertion_order >::type::iterator entry)
Definition: txmempool.h:1001
CompareTxMemPoolEntryByAncestorFee
Definition: txmempool.h:321
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:1112
CTxMemPoolEntry::m_parents
Parents m_parents
Definition: txmempool.h:89
CTxMemPool::ClearPrioritisation
void ClearPrioritisation(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:940
CTxMemPoolEntry::GetTime
std::chrono::seconds GetTime() const
Definition: txmempool.h:125
CTxMemPoolEntry::GetSharedTx
CTransactionRef GetSharedTx() const
Definition: txmempool.h:121
CTxMemPoolEntry::GetMemPoolParentsConst
const Parents & GetMemPoolParentsConst() const
Definition: txmempool.h:153
CTxMemPool::AddUnbroadcastTx
void AddUnbroadcastTx(const uint256 &txid)
Adds a transaction to the unbroadcast set.
Definition: txmempool.h:800
CTxMemPool::SetIsLoaded
void SetIsLoaded(bool loaded)
Sets the current loaded state.
Definition: txmempool.cpp:1195
CTxMemPool::m_epoch
bool m_epoch
Definition: txmempool.h:881
descendant_score
Definition: txmempool.h:362
MemPoolRemovalReason::EXPIRY
@ EXPIRY
Expired from mempool.
CTxMemPoolEntry::GetMemPoolParents
Parents & GetMemPoolParents() const
Definition: txmempool.h:155
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:306
update_lock_points::lp
const LockPoints & lp
Definition: txmempool.h:211
CTxMemPool::ApplyDelta
void ApplyDelta(const uint256 &hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:930
update_lock_points::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:208
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:238
update_ancestor_state::modifyCount
int64_t modifyCount
Definition: txmempool.h:190
CTxMemPoolEntry::vTxHashesIdx
size_t vTxHashesIdx
Index in mempool's vTxHashes.
Definition: txmempool.h:158
mempoolentry_wtxid
Definition: txmempool.h:230
CTxMemPoolEntry::nTxWeight
const size_t nTxWeight
... and avoid recomputing tx weight (also used for GetTxSize())
Definition: txmempool.h:92
CTxMemPoolEntry::Parents
std::set< CTxMemPoolEntryRef, CompareIteratorByHash > Parents
Definition: txmempool.h:84
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:1002
DisconnectedBlockTransactions::~DisconnectedBlockTransactions
~DisconnectedBlockTransactions()
Definition: txmempool.h:967
CTxMemPool::GetTransactionsUpdated
unsigned int GetTransactionsUpdated() const
Definition: txmempool.cpp:406
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:534
CTxMemPool::CalculateDescendantMaximum
uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1155
update_ancestor_state
Definition: txmempool.h:178
CTxMemPoolEntry::nSizeWithAncestors
uint64_t nSizeWithAncestors
Definition: txmempool.h:110
CCoinsViewMemPool::CCoinsViewMemPool
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn)
Definition: txmempool.cpp:977
CFeeRate
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
TxMempoolInfo::tx
CTransactionRef tx
The transaction itself.
Definition: txmempool.h:375
update_descendant_state::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:169
CTxMemPoolEntry::m_children
Children m_children
Definition: txmempool.h:90
CTxMemPool::queryHashes
void queryHashes(std::vector< uint256 > &vtxid) const
Definition: txmempool.cpp:849
CTxMemPool::UpdateEntryForAncestors
void UpdateEntryForAncestors(txiter it, const setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs)
Set ancestor state for an entry.
Definition: txmempool.cpp:292
CTxMemPoolEntry::nUsageSize
const size_t nUsageSize
... and total memory usage
Definition: txmempool.h:93
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:105
CTxMemPoolEntry::nModFeesWithDescendants
CAmount nModFeesWithDescendants
... and total fees (all including us)
Definition: txmempool.h:106
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:62
CCoinsViewMemPool::mempool
const CTxMemPool & mempool
Definition: txmempool.h:913
CTxMemPool::GUARDED_BY
bool m_is_loaded GUARDED_BY(cs)
Definition: txmempool.h:498
GenTxid::IsWtxid
bool IsWtxid() const
Definition: transaction.h:396
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:888
CTxMemPoolEntry::GetSigOpCostWithAncestors
int64_t GetSigOpCostWithAncestors() const
Definition: txmempool.h:151
CTxMemPool::GUARDED_BY
uint64_t m_sequence_number GUARDED_BY(cs)
Definition: txmempool.h:494
insertion_order
Definition: txmempool.h:940
LockPoints::maxInputBlock
CBlockIndex * maxInputBlock
Definition: txmempool.h:49
CTxMemPoolEntry::GetCountWithAncestors
uint64_t GetCountWithAncestors() const
Definition: txmempool.h:148
CompareIteratorByHash
Definition: txmempool.h:52
random.h
update_descendant_state::modifySize
int64_t modifySize
Definition: txmempool.h:173
TxMempoolInfo::nFeeDelta
int64_t nFeeDelta
The fee delta.
Definition: txmempool.h:387
RecursiveDynamicUsage
static size_t RecursiveDynamicUsage(const CScript &script)
Definition: core_memusage.h:12
CTxMemPoolEntry::GetModFeesWithAncestors
CAmount GetModFeesWithAncestors() const
Definition: txmempool.h:150
entry_time
Definition: txmempool.h:363
CTxMemPool::cs
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition: txmempool.h:563
CTxMemPool::GetAndIncrementSequence
uint64_t GetAndIncrementSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Guards this internal counter for external reporting.
Definition: txmempool.h:826
CTxMemPool::get
CTransactionRef get(const uint256 &hash) const
Definition: txmempool.cpp:880
CCoinsViewMemPool::m_temp_added
std::unordered_map< COutPoint, Coin, SaltedOutpointHasher > m_temp_added
Coins made available by transactions being validated.
Definition: txmempool.h:911
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:959
CTxMemPoolEntry::GetSigOpCost
int64_t GetSigOpCost() const
Definition: txmempool.h:127
CompareTxMemPoolEntryByEntryTime
Definition: txmempool.h:308
CTxMemPool::nTransactionsUpdated
std::atomic< unsigned int > nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
Definition: txmempool.h:479
CTxMemPoolEntry::nModFeesWithAncestors
CAmount nModFeesWithAncestors
Definition: txmempool.h:111
update_descendant_state
Definition: txmempool.h:163
Coin
A UTXO entry.
Definition: coins.h:30
Epoch::Marker
Definition: epochguard.h:49
mempoolentry_wtxid::result_type
uint256 result_type
Definition: txmempool.h:232
CTxMemPool::UpdateChild
void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1058
CTxMemPoolEntry::UpdateAncestorState
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps)
Definition: txmempool.cpp:383
CTxMemPool::GetTotalFee
CAmount GetTotalFee() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:771
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:969
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:1177
SaltedTxidHasher
Definition: hasher.h:12
CompareTxMemPoolEntryByDescendantScore::GetModFeeAndSize
void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee, double &size) const
Definition: txmempool.h:270
update_fee_delta::update_fee_delta
update_fee_delta(int64_t _feeDelta)
Definition: txmempool.h:196
CTxMemPoolEntry::UpdateDescendantState
void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount)
Definition: txmempool.cpp:374
update_ancestor_state::modifySigOpsCost
int64_t modifySigOpsCost
Definition: txmempool.h:191
CBlockPolicyEstimator
Definition: fees.h:131
update_descendant_state::modifyFee
CAmount modifyFee
Definition: txmempool.h:174
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:830
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:957
LockPoints::height
int height
Definition: txmempool.h:44
MemPoolRemovalReason::SIZELIMIT
@ SIZELIMIT
Removed in size limiting.
CTxMemPool::removeConflicts
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:606
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:154
CTxMemPool::m_check_ratio
const int m_check_ratio
Value n means that 1 times in n we check.
Definition: txmempool.h:478
CTxMemPool::UpdateParent
void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1069
CTxMemPool::RemoveUnbroadcastTx
void RemoveUnbroadcastTx(const uint256 &txid, const bool unchecked=false)
Removes a transaction from the unbroadcast set.
Definition: txmempool.cpp:1015
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:109
uint256
256-bit opaque blob.
Definition: uint256.h:124
CTxMemPoolEntry::nFee
const CAmount nFee
Cached to avoid expensive parent-transaction lookups.
Definition: txmempool.h:91
MemPoolRemovalReason::REPLACED
@ REPLACED
Removed for replacement.
CompareIteratorByHash::operator()
bool operator()(const T &a, const T &b) const
Definition: txmempool.h:61
CChainState
CChainState stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:546
CompareTxMemPoolEntryByScore
Definition: txmempool.h:294
CTxMemPoolEntry::UpdateFeeDelta
void UpdateFeeDelta(int64_t feeDelta)
Definition: txmempool.cpp:42
CCoinsViewMemPool::GetCoin
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: txmempool.cpp:979
coins.h
CompareIteratorByHash::operator()
bool operator()(const std::reference_wrapper< T > &a, const std::reference_wrapper< T > &b) const
Definition: txmempool.h:56
DisconnectedBlockTransactions::clear
void clear()
Definition: txmempool.h:1007
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:952
CTxMemPoolEntry::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.h:129
ancestor_score
Definition: txmempool.h:364
DisconnectedBlockTransactions::removeForBlock
void removeForBlock(const std::vector< CTransactionRef > &vtx)
Definition: txmempool.h:985
mempoolentry_txid::operator()
result_type operator()(const CTxMemPoolEntry &entry) const
Definition: txmempool.h:218
hasher.h
index_by_wtxid
Definition: txmempool.h:365
CTxMemPool::PrioritiseTransaction
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
Definition: txmempool.cpp:900
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:314
CTxMemPoolEntry::GetMemPoolChildrenConst
const Children & GetMemPoolChildrenConst() const
Definition: txmempool.h:154
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:1032
CTxMemPoolEntry::tx
const CTransactionRef tx
Definition: txmempool.h:88
update_ancestor_state::update_ancestor_state
update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost)
Definition: txmempool.h:180
CTxMemPool::LOCKS_EXCLUDED
void cs_main LOCKS_EXCLUDED(m_epoch)
CTxMemPool::exists
bool exists(const GenTxid &gtxid) const
Definition: txmempool.h:777
DisconnectedBlockTransactions
Definition: txmempool.h:942
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:277
GenTxid::GetHash
const uint256 & GetHash() const
Definition: transaction.h:397
CTxMemPool::IsUnbroadcastTx
bool IsUnbroadcastTx(const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns whether a txid is in the unbroadcast set.
Definition: txmempool.h:819
CTxMemPool::exists
bool exists(const uint256 &txid) const
Definition: txmempool.h:785
CCoinsViewBacked
CCoinsView backed by another CCoinsView.
Definition: coins.h:194
CTxMemPoolEntry::GetLockPoints
const LockPoints & GetLockPoints() const
Definition: txmempool.h:130
CTxMemPool::addUnchecked
void check(CChainState &active_chainstate) 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:634
CompareTxMemPoolEntryByDescendantScore
Definition: txmempool.h:249
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:344
DisconnectedBlockTransactions::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.h:974
CTxMemPoolEntry
Definition: txmempool.h:79
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:393
DisconnectedBlockTransactions::queuedTx
indexed_disconnected_transactions queuedTx
Definition: txmempool.h:969
CTxMemPool::infoAll
std::vector< TxMempoolInfo > infoAll() const
Definition: txmempool.cpp:866
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:946
CompareTxMemPoolEntryByAncestorFee::operator()
bool operator()(const T &a, const T &b) const
Definition: txmempool.h:325
update_descendant_state::update_descendant_state
update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount)
Definition: txmempool.h:165
LockPoints
Definition: txmempool.h:40
mempoolentry_txid
Definition: txmempool.h:215
CTxMemPool::trackPackageRemoved
void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1104
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:1024
CCoinsViewMemPool
CCoinsView that brings transactions from a mempool into view.
Definition: txmempool.h:905
CTxMemPool::size
unsigned long size() const
Definition: txmempool.h:759
TxMempoolInfo
Information about a mempool transaction.
Definition: txmempool.h:372
CTxMemPoolEntry::UpdateLockPoints
void UpdateLockPoints(const LockPoints &lp)
Definition: txmempool.cpp:49
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:252
CTxMemPool::CompareDepthAndScore
bool CompareDepthAndScore(const uint256 &hasha, const uint256 &hashb, bool wtxid=false)
Definition: txmempool.cpp:804
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:144
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:38
update_ancestor_state::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:184
update_fee_delta::feeDelta
int64_t feeDelta
Definition: txmempool.h:201
CTransaction::GetWitnessHash
const uint256 & GetWitnessHash() const
Definition: transaction.h:303
CTxMemPool::info
TxMempoolInfo info(const uint256 &hash) const
Definition: txmempool.cpp:898
update_ancestor_state::modifySize
int64_t modifySize
Definition: txmempool.h:188
CTxMemPool::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.cpp:1009
CTxMemPoolEntry::GetTxSize
size_t GetTxSize() const
Definition: txmempool.cpp:54
CTxMemPoolEntry::GetTxWeight
size_t GetTxWeight() const
Definition: txmempool.h:124
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
update_ancestor_state::modifyFee
CAmount modifyFee
Definition: txmempool.h:189
CTxMemPoolEntry::GetMemPoolChildren
Children & GetMemPoolChildren() const
Definition: txmempool.h:156
MemPoolRemovalReason::BLOCK
@ BLOCK
Removed for block.
mempoolentry_txid::result_type
uint256 result_type
Definition: txmempool.h:217
TxMempoolInfo::m_time
std::chrono::seconds m_time
Time the transaction entered the mempool.
Definition: txmempool.h:378
CTxMemPool::GetTotalTxSize
uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:765
CTxMemPoolEntry::GetSizeWithAncestors
uint64_t GetSizeWithAncestors() const
Definition: txmempool.h:149
TxMempoolInfo::fee
CAmount fee
Fee of the transaction.
Definition: txmempool.h:381
T
#define T(expected, seed, data)
CTxMemPoolEntry::GetCountWithDescendants
uint64_t GetCountWithDescendants() const
Definition: txmempool.h:142
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:145
CTxMemPoolEntry::entryHeight
const unsigned int entryHeight
Chain height when entering the mempool.
Definition: txmempool.h:95
CTxMemPool::cacheMap
std::map< txiter, setEntries, CompareIteratorByHash > cacheMap
Definition: txmempool.h:573
CTxMemPool::isSpent
bool isSpent(const COutPoint &outpoint) const
Definition: txmempool.cpp:400
amount.h
CTxMemPoolEntry::sigOpCost
const int64_t sigOpCost
Total sigop cost.
Definition: txmempool.h:97
CTxMemPoolEntry::CTxMemPoolEntryRef
std::reference_wrapper< const CTxMemPoolEntry > CTxMemPoolEntryRef
Definition: txmempool.h:82
CTxMemPool::clear
void clear()
Definition: txmempool.cpp:668
CompareTxMemPoolEntryByEntryTime::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:311
CTxMemPool::_clear
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:655
mempoolentry_wtxid::operator()
result_type operator()(const CTxMemPoolEntry &entry) const
Definition: txmempool.h:233
CTxMemPool::minerPolicyEstimator
CBlockPolicyEstimator *const minerPolicyEstimator
Definition: txmempool.h:480
CTxMemPoolEntry::GetSizeWithDescendants
uint64_t GetSizeWithDescendants() const
Definition: txmempool.h:143
MemPoolRemovalReason::CONFLICT
@ CONFLICT
Removed for conflict with in-block transaction.
MemPoolRemovalReason::REORG
@ REORG
Removed for reorganization.
update_lock_points::update_lock_points
update_lock_points(const LockPoints &_lp)
Definition: txmempool.h:206
update_fee_delta::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:198
DisconnectedBlockTransactions::cachedInnerUsage
uint64_t cachedInnerUsage
Definition: txmempool.h:970
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:24
CTxMemPoolEntry::m_epoch_marker
Epoch::Marker m_epoch_marker
epoch when last touched, useful for graph algorithms
Definition: txmempool.h:159
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:626
CTxMemPool::removeForReorg
void removeForReorg(CChainState &active_chainstate, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs
Definition: txmempool.cpp:566
CTxMemPool::removeRecursive
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:536
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:117
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:512
CTxMemPoolEntry::GetTx
const CTransaction & GetTx() const
Definition: txmempool.h:120