Bitcoin Core  21.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 <primitives/transaction.h>
22 #include <random.h>
23 #include <sync.h>
24 #include <util/epochguard.h>
25 #include <util/hasher.h>
26 
27 #include <boost/multi_index_container.hpp>
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 
32 class CBlockIndex;
33 class CChainState;
34 extern RecursiveMutex cs_main;
35 
37 static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
38 
39 struct LockPoints
40 {
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;
45  int64_t time;
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  LockPoints() : height(0), time(0), maxInputBlock(nullptr) { }
52 };
53 
55  // SFINAE for T where T is either a pointer type (e.g., a txiter) or a reference_wrapper<T>
56  // (e.g. a wrapped CTxMemPoolEntry&)
57  template <typename T>
58  bool operator()(const std::reference_wrapper<T>& a, const std::reference_wrapper<T>& b) const
59  {
60  return a.get().GetTx().GetHash() < b.get().GetTx().GetHash();
61  }
62  template <typename T>
63  bool operator()(const T& a, const T& b) const
64  {
65  return a->GetTx().GetHash() < b->GetTx().GetHash();
66  }
67 };
68 
82 {
83 public:
84  typedef std::reference_wrapper<const CTxMemPoolEntry> CTxMemPoolEntryRef;
85  // two aliases, should the types ever diverge
86  typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> Parents;
87  typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> Children;
88 
89 private:
91  mutable Parents m_parents;
93  const CAmount nFee;
94  const size_t nTxWeight;
95  const size_t nUsageSize;
96  const int64_t nTime;
97  const unsigned int entryHeight;
98  const bool spendsCoinbase;
99  const int64_t sigOpCost;
100  int64_t feeDelta;
102 
103  // Information about descendants of this transaction that are in the
104  // mempool; if we remove this transaction we must remove all of these
105  // descendants as well.
109 
110  // Analogous statistics for ancestor transactions
115 
116 public:
117  CTxMemPoolEntry(const CTransactionRef& _tx, const CAmount& _nFee,
118  int64_t _nTime, unsigned int _entryHeight,
119  bool spendsCoinbase,
120  int64_t nSigOpsCost, LockPoints lp);
121 
122  const CTransaction& GetTx() const { return *this->tx; }
123  CTransactionRef GetSharedTx() const { return this->tx; }
124  const CAmount& GetFee() const { return nFee; }
125  size_t GetTxSize() const;
126  size_t GetTxWeight() const { return nTxWeight; }
127  std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
128  unsigned int GetHeight() const { return entryHeight; }
129  int64_t GetSigOpCost() const { return sigOpCost; }
130  int64_t GetModifiedFee() const { return nFee + feeDelta; }
131  size_t DynamicMemoryUsage() const { return nUsageSize; }
132  const LockPoints& GetLockPoints() const { return lockPoints; }
133 
134  // Adjusts the descendant state.
135  void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount);
136  // Adjusts the ancestor state
137  void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps);
138  // Updates the fee delta used for mining priority score, and the
139  // modified fees with descendants.
140  void UpdateFeeDelta(int64_t feeDelta);
141  // Update the LockPoints after a reorg
142  void UpdateLockPoints(const LockPoints& lp);
143 
144  uint64_t GetCountWithDescendants() const { return nCountWithDescendants; }
145  uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
147 
148  bool GetSpendsCoinbase() const { return spendsCoinbase; }
149 
150  uint64_t GetCountWithAncestors() const { return nCountWithAncestors; }
151  uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
154 
155  const Parents& GetMemPoolParentsConst() const { return m_parents; }
156  const Children& GetMemPoolChildrenConst() const { return m_children; }
157  Parents& GetMemPoolParents() const { return m_parents; }
159 
160  mutable size_t vTxHashesIdx;
162 };
163 
164 // Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index.
166 {
167  update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) :
168  modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount)
169  {}
170 
173 
174  private:
175  int64_t modifySize;
177  int64_t modifyCount;
178 };
179 
181 {
182  update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost) :
183  modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost)
184  {}
185 
188 
189  private:
190  int64_t modifySize;
192  int64_t modifyCount;
194 };
195 
197 {
198  explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
199 
201 
202 private:
203  int64_t feeDelta;
204 };
205 
207 {
208  explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
209 
211 
212 private:
213  const LockPoints& lp;
214 };
215 
216 // extracts a transaction hash from CTxMemPoolEntry or CTransactionRef
218 {
221  {
222  return entry.GetTx().GetHash();
223  }
224 
226  {
227  return tx->GetHash();
228  }
229 };
230 
231 // extracts a transaction witness-hash from CTxMemPoolEntry or CTransactionRef
233 {
236  {
237  return entry.GetTx().GetWitnessHash();
238  }
239 
241  {
242  return tx->GetWitnessHash();
243  }
244 };
245 
246 
252 {
253 public:
254  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
255  {
256  double a_mod_fee, a_size, b_mod_fee, b_size;
257 
258  GetModFeeAndSize(a, a_mod_fee, a_size);
259  GetModFeeAndSize(b, b_mod_fee, b_size);
260 
261  // Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
262  double f1 = a_mod_fee * b_size;
263  double f2 = a_size * b_mod_fee;
264 
265  if (f1 == f2) {
266  return a.GetTime() >= b.GetTime();
267  }
268  return f1 < f2;
269  }
270 
271  // Return the fee/size we're using for sorting this entry.
272  void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee, double &size) const
273  {
274  // Compare feerate with descendants to feerate of the transaction, and
275  // return the fee/size for the max.
276  double f1 = (double)a.GetModifiedFee() * a.GetSizeWithDescendants();
277  double f2 = (double)a.GetModFeesWithDescendants() * a.GetTxSize();
278 
279  if (f2 > f1) {
280  mod_fee = a.GetModFeesWithDescendants();
281  size = a.GetSizeWithDescendants();
282  } else {
283  mod_fee = a.GetModifiedFee();
284  size = a.GetTxSize();
285  }
286  }
287 };
288 
297 {
298 public:
299  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
300  {
301  double f1 = (double)a.GetFee() * b.GetTxSize();
302  double f2 = (double)b.GetFee() * a.GetTxSize();
303  if (f1 == f2) {
304  return b.GetTx().GetHash() < a.GetTx().GetHash();
305  }
306  return f1 > f2;
307  }
308 };
309 
311 {
312 public:
313  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
314  {
315  return a.GetTime() < b.GetTime();
316  }
317 };
318 
324 {
325 public:
326  template<typename T>
327  bool operator()(const T& a, const T& b) const
328  {
329  double a_mod_fee, a_size, b_mod_fee, b_size;
330 
331  GetModFeeAndSize(a, a_mod_fee, a_size);
332  GetModFeeAndSize(b, b_mod_fee, b_size);
333 
334  // Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
335  double f1 = a_mod_fee * b_size;
336  double f2 = a_size * b_mod_fee;
337 
338  if (f1 == f2) {
339  return a.GetTx().GetHash() < b.GetTx().GetHash();
340  }
341  return f1 > f2;
342  }
343 
344  // Return the fee/size we're using for sorting this entry.
345  template <typename T>
346  void GetModFeeAndSize(const T &a, double &mod_fee, double &size) const
347  {
348  // Compare feerate with ancestors to feerate of the transaction, and
349  // return the fee/size for the min.
350  double f1 = (double)a.GetModifiedFee() * a.GetSizeWithAncestors();
351  double f2 = (double)a.GetModFeesWithAncestors() * a.GetTxSize();
352 
353  if (f1 > f2) {
354  mod_fee = a.GetModFeesWithAncestors();
355  size = a.GetSizeWithAncestors();
356  } else {
357  mod_fee = a.GetModifiedFee();
358  size = a.GetTxSize();
359  }
360  }
361 };
362 
363 // Multi_index tag names
365 struct entry_time {};
366 struct ancestor_score {};
367 struct index_by_wtxid {};
368 
370 
375 {
378 
380  std::chrono::seconds m_time;
381 
384 
386  size_t vsize;
387 
389  int64_t nFeeDelta;
390 };
391 
396  EXPIRY,
397  SIZELIMIT,
398  REORG,
399  BLOCK,
400  CONFLICT,
401  REPLACED,
402 };
403 
478 {
479 protected:
480  const int m_check_ratio;
481  std::atomic<unsigned int> nTransactionsUpdated{0};
483 
484  uint64_t totalTxSize GUARDED_BY(cs);
485  CAmount m_total_fee GUARDED_BY(cs);
486  uint64_t cachedInnerUsage GUARDED_BY(cs);
487 
488  mutable int64_t lastRollingFeeUpdate;
490  mutable double rollingMinimumFeeRate;
491  mutable Epoch m_epoch GUARDED_BY(cs);
492 
493  // In-memory counter for external mempool tracking purposes.
494  // This number is incremented once every time a transaction
495  // is added or removed from the mempool for any reason.
496  mutable uint64_t m_sequence_number{1};
497 
499 
500  bool m_is_loaded GUARDED_BY(cs){false};
501 
502 public:
503 
504  static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12; // public only for testing
505 
506  typedef boost::multi_index_container<
508  boost::multi_index::indexed_by<
509  // sorted by txid
510  boost::multi_index::hashed_unique<mempoolentry_txid, SaltedTxidHasher>,
511  // sorted by wtxid
512  boost::multi_index::hashed_unique<
513  boost::multi_index::tag<index_by_wtxid>,
516  >,
517  // sorted by fee rate
518  boost::multi_index::ordered_non_unique<
519  boost::multi_index::tag<descendant_score>,
520  boost::multi_index::identity<CTxMemPoolEntry>,
522  >,
523  // sorted by entry time
524  boost::multi_index::ordered_non_unique<
525  boost::multi_index::tag<entry_time>,
526  boost::multi_index::identity<CTxMemPoolEntry>,
528  >,
529  // sorted by fee rate with ancestors
530  boost::multi_index::ordered_non_unique<
531  boost::multi_index::tag<ancestor_score>,
532  boost::multi_index::identity<CTxMemPoolEntry>,
534  >
535  >
537 
567 
568  using txiter = indexed_transaction_set::nth_index<0>::type::const_iterator;
569  std::vector<std::pair<uint256, txiter>> vTxHashes GUARDED_BY(cs);
570 
571  typedef std::set<txiter, CompareIteratorByHash> setEntries;
572 
574 private:
575  typedef std::map<txiter, setEntries, CompareIteratorByHash> cacheMap;
576 
577 
578  void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs);
579  void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs);
580 
581  std::vector<indexed_transaction_set::const_iterator> GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs);
582 
586  std::set<uint256> m_unbroadcast_txids GUARDED_BY(cs);
587 
588 public:
589  indirectmap<COutPoint, const CTransaction*> mapNextTx GUARDED_BY(cs);
591 
600  explicit CTxMemPool(CBlockPolicyEstimator* estimator = nullptr, int check_ratio = 0);
601 
608  void check(CChainState& active_chainstate) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
609 
610  // addUnchecked must updated state for all ancestors of a given transaction,
611  // to track size/count of descendant transactions. First version of
612  // addUnchecked can be used to have it call CalculateMemPoolAncestors(), and
613  // then invoke the second version.
614  // Note that addUnchecked is ONLY called from ATMP outside of tests
615  // and any other callers may break wallet's in-mempool tracking (due to
616  // lack of CValidationInterface::TransactionAddedToMempool callbacks).
617  void addUnchecked(const CTxMemPoolEntry& entry, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
618  void addUnchecked(const CTxMemPoolEntry& entry, setEntries& setAncestors, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
619 
621  void removeForReorg(CChainState& active_chainstate, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
623  void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
624 
625  void clear();
626  void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free
627  bool CompareDepthAndScore(const uint256& hasha, const uint256& hashb, bool wtxid=false);
628  void queryHashes(std::vector<uint256>& vtxid) const;
629  bool isSpent(const COutPoint& outpoint) const;
630  unsigned int GetTransactionsUpdated() const;
631  void AddTransactionsUpdated(unsigned int n);
636  bool HasNoInputsOf(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs);
637 
639  void PrioritiseTransaction(const uint256& hash, const CAmount& nFeeDelta);
640  void ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs);
642 
644  const CTransaction* GetConflictTx(const COutPoint& prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs);
645 
647  std::optional<txiter> GetIter(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);
648 
650  setEntries GetIterSet(const std::set<uint256>& hashes) const EXCLUSIVE_LOCKS_REQUIRED(cs);
651 
659  void RemoveStaged(setEntries& stage, bool updateDescendants, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
660 
670  void UpdateTransactionsFromBlock(const std::vector<uint256>& vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main) LOCKS_EXCLUDED(m_epoch);
671 
682  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);
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 
710  void GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) const;
711 
713  bool IsLoaded() const;
714 
716  void SetIsLoaded(bool loaded);
717 
718  unsigned long size() const
719  {
720  LOCK(cs);
721  return mapTx.size();
722  }
723 
725  {
727  return totalTxSize;
728  }
729 
731  {
733  return m_total_fee;
734  }
735 
736  bool exists(const GenTxid& gtxid) const
737  {
738  LOCK(cs);
739  if (gtxid.IsWtxid()) {
740  return (mapTx.get<index_by_wtxid>().count(gtxid.GetHash()) != 0);
741  }
742  return (mapTx.count(gtxid.GetHash()) != 0);
743  }
744  bool exists(const uint256& txid) const { return exists(GenTxid{false, txid}); }
745 
746  CTransactionRef get(const uint256& hash) const;
748  {
750  return mapTx.project<0>(mapTx.get<index_by_wtxid>().find(wtxid));
751  }
752  TxMempoolInfo info(const uint256& hash) const;
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(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 
864 {
865 protected:
867 
868 public:
869  CCoinsViewMemPool(CCoinsView* baseIn, const CTxMemPool& mempoolIn);
870  bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
871 };
872 
888 // multi_index tag names
889 struct txid_index {};
890 struct insertion_order {};
891 
893  typedef boost::multi_index_container<
895  boost::multi_index::indexed_by<
896  // sorted by txid
897  boost::multi_index::hashed_unique<
898  boost::multi_index::tag<txid_index>,
901  >,
902  // sorted by order in the blockchain
903  boost::multi_index::sequenced<
904  boost::multi_index::tag<insertion_order>
905  >
906  >
908 
909  // It's almost certainly a logic bug if we don't clear out queuedTx before
910  // destruction, as we add to it while disconnecting blocks, and then we
911  // need to re-process remaining transactions to ensure mempool consistency.
912  // For now, assert() that we've emptied out this object on destruction.
913  // This assert() can always be removed if the reorg-processing code were
914  // to be refactored such that this assumption is no longer true (for
915  // instance if there was some other way we cleaned up the mempool after a
916  // reorg, besides draining this object).
918 
920  uint64_t cachedInnerUsage = 0;
921 
922  // Estimate the overhead of queuedTx to be 6 pointers + an allocation, as
923  // no exact formula for boost::multi_index_contained is implemented.
924  size_t DynamicMemoryUsage() const {
925  return memusage::MallocUsage(sizeof(CTransactionRef) + 6 * sizeof(void*)) * queuedTx.size() + cachedInnerUsage;
926  }
927 
929  {
930  queuedTx.insert(tx);
932  }
933 
934  // Remove entries based on txid_index, and update memory usage.
935  void removeForBlock(const std::vector<CTransactionRef>& vtx)
936  {
937  // Short-circuit in the common case of a block being added to the tip
938  if (queuedTx.empty()) {
939  return;
940  }
941  for (auto const &tx : vtx) {
942  auto it = queuedTx.find(tx->GetHash());
943  if (it != queuedTx.end()) {
945  queuedTx.erase(it);
946  }
947  }
948  }
949 
950  // Remove an entry by insertion_order index, and update memory usage.
951  void removeEntry(indexed_disconnected_transactions::index<insertion_order>::type::iterator entry)
952  {
954  queuedTx.get<insertion_order>().erase(entry);
955  }
956 
957  void clear()
958  {
959  cachedInnerUsage = 0;
960  queuedTx.clear();
961  }
962 };
963 
964 #endif // BITCOIN_TXMEMPOOL_H
CTxMemPoolEntry::GetSpendsCoinbase
bool GetSpendsCoinbase() const
Definition: txmempool.h:148
CTxMemPoolEntry::nSigOpCostWithAncestors
int64_t nSigOpCostWithAncestors
Definition: txmempool.h:114
CTxMemPoolEntry::nCountWithDescendants
uint64_t nCountWithDescendants
number of descendant transactions
Definition: txmempool.h:106
CTxMemPool::setEntries
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:571
DisconnectedBlockTransactions::addTransaction
void addTransaction(const CTransactionRef &tx)
Definition: txmempool.h:928
CTxMemPool::AddTransactionsUpdated
void AddTransactionsUpdated(unsigned int n)
Definition: txmempool.cpp:352
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:1008
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:409
CTxMemPool::GetUnbroadcastTxs
std::set< uint256 > GetUnbroadcastTxs() const
Returns transactions in unbroadcast set.
Definition: txmempool.h:771
CTxMemPoolEntry::feeDelta
int64_t feeDelta
Used for determining the priority of the transaction for mining in a block.
Definition: txmempool.h:100
update_fee_delta
Definition: txmempool.h:196
CTxMemPoolEntry::GetHeight
unsigned int GetHeight() const
Definition: txmempool.h:128
CTxMemPoolEntry::Children
std::set< CTxMemPoolEntryRef, CompareIteratorByHash > Children
Definition: txmempool.h:87
CTxMemPoolEntry::nCountWithAncestors
uint64_t nCountWithAncestors
Definition: txmempool.h:111
epochguard.h
CTxMemPoolEntry::GetFee
const CAmount & GetFee() const
Definition: txmempool.h:124
CTxMemPool::ROLLING_FEE_HALFLIFE
static const int ROLLING_FEE_HALFLIFE
Definition: txmempool.h:504
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:386
CTxMemPoolEntry::nTime
const int64_t nTime
Local time when entering the mempool.
Definition: txmempool.h:96
flags
int flags
Definition: bitcoin-tx.cpp:512
txid_index
DisconnectedBlockTransactions.
Definition: txmempool.h:889
CompareTxMemPoolEntryByScore::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:299
CTxMemPoolEntry::lockPoints
LockPoints lockPoints
Track the height and time at which tx was final.
Definition: txmempool.h:101
update_lock_points
Definition: txmempool.h:206
CTxMemPool::GetSortedDepthAndScore
std::vector< indexed_transaction_set::const_iterator > GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:777
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:177
transaction.h
CTxMemPool::cs_main
void check(CChainState &active_chainstate) const EXCLUSIVE_LOCKS_REQUIRED(void cs_main
Definition: txmempool.h:617
CTxMemPool::txiter
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
Definition: txmempool.h:568
CTxMemPool::IsLoaded
bool IsLoaded() const
Definition: txmempool.cpp:1115
CTxMemPoolEntry::GetModifiedFee
int64_t GetModifiedFee() const
Definition: txmempool.h:130
CTxMemPool::get_iter_from_wtxid
txiter get_iter_from_wtxid(const uint256 &wtxid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:747
CTxMemPool::GetTransactionAncestry
void GetTransactionAncestry(const uint256 &txid, size_t &ancestors, size_t &descendants) const
Calculate the ancestor and descendant count for the given transaction.
Definition: txmempool.cpp:1105
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:477
CTxMemPoolEntry::spendsCoinbase
const bool spendsCoinbase
keep track of transactions that spend a coinbase
Definition: txmempool.h:98
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:951
CompareTxMemPoolEntryByAncestorFee
Definition: txmempool.h:323
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:1040
CTxMemPoolEntry::m_parents
Parents m_parents
Definition: txmempool.h:91
CTxMemPool::ClearPrioritisation
void ClearPrioritisation(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:882
CTxMemPoolEntry::GetTime
std::chrono::seconds GetTime() const
Definition: txmempool.h:127
CTxMemPoolEntry::GetSharedTx
CTransactionRef GetSharedTx() const
Definition: txmempool.h:123
CTxMemPoolEntry::GetMemPoolParentsConst
const Parents & GetMemPoolParentsConst() const
Definition: txmempool.h:155
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:1121
CTxMemPool::m_epoch
bool m_epoch
Definition: txmempool.h:840
descendant_score
Definition: txmempool.h:364
MemPoolRemovalReason::EXPIRY
@ EXPIRY
Expired from mempool.
CTxMemPoolEntry::GetMemPoolParents
Parents & GetMemPoolParents() const
Definition: txmempool.h:157
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:247
update_lock_points::lp
const LockPoints & lp
Definition: txmempool.h:213
CTxMemPool::ApplyDelta
void ApplyDelta(const uint256 &hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:872
update_lock_points::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:210
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:153
update_ancestor_state::modifyCount
int64_t modifyCount
Definition: txmempool.h:192
CTxMemPoolEntry::vTxHashesIdx
size_t vTxHashesIdx
Index in mempool's vTxHashes.
Definition: txmempool.h:160
mempoolentry_wtxid
Definition: txmempool.h:232
CTxMemPoolEntry::nTxWeight
const size_t nTxWeight
... and avoid recomputing tx weight (also used for GetTxSize())
Definition: txmempool.h:94
CTxMemPoolEntry::Parents
std::set< CTxMemPoolEntryRef, CompareIteratorByHash > Parents
Definition: txmempool.h:86
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:386
DisconnectedBlockTransactions::~DisconnectedBlockTransactions
~DisconnectedBlockTransactions()
Definition: txmempool.h:917
CTxMemPool::GetTransactionsUpdated
unsigned int GetTransactionsUpdated() const
Definition: txmempool.cpp:347
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:536
CTxMemPool::CalculateDescendantMaximum
uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1083
update_ancestor_state
Definition: txmempool.h:180
CTxMemPoolEntry::nSizeWithAncestors
uint64_t nSizeWithAncestors
Definition: txmempool.h:112
CCoinsViewMemPool::CCoinsViewMemPool
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn)
Definition: txmempool.cpp:919
CFeeRate
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
TxMempoolInfo::tx
CTransactionRef tx
The transaction itself.
Definition: txmempool.h:377
update_descendant_state::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:171
CTxMemPoolEntry::m_children
Children m_children
Definition: txmempool.h:92
CTxMemPool::queryHashes
void queryHashes(std::vector< uint256 > &vtxid) const
Definition: txmempool.cpp:791
CTxMemPool::UpdateEntryForAncestors
void UpdateEntryForAncestors(txiter it, const setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs)
Set ancestor state for an entry.
Definition: txmempool.cpp:233
CTxMemPoolEntry::nUsageSize
const size_t nUsageSize
... and total memory usage
Definition: txmempool.h:95
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
CCoinsView
Abstract view on the open txout dataset.
Definition: coins.h:159
CTxMemPoolEntry::nSizeWithDescendants
uint64_t nSizeWithDescendants
... and size
Definition: txmempool.h:107
CTxMemPoolEntry::nModFeesWithDescendants
CAmount nModFeesWithDescendants
... and total fees (all including us)
Definition: txmempool.h:108
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:61
CCoinsViewMemPool::mempool
const CTxMemPool & mempool
Definition: txmempool.h:866
CTxMemPool::GUARDED_BY
bool m_is_loaded GUARDED_BY(cs)
Definition: txmempool.h:500
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...
CTxMemPool::it
return !it visited * it
Definition: txmempool.h:847
CTxMemPoolEntry::GetSigOpCostWithAncestors
int64_t GetSigOpCostWithAncestors() const
Definition: txmempool.h:153
insertion_order
Definition: txmempool.h:890
LockPoints::maxInputBlock
CBlockIndex * maxInputBlock
Definition: txmempool.h:49
CTxMemPoolEntry::GetCountWithAncestors
uint64_t GetCountWithAncestors() const
Definition: txmempool.h:150
CompareIteratorByHash
Definition: txmempool.h:54
random.h
update_descendant_state::modifySize
int64_t modifySize
Definition: txmempool.h:175
CTxMemPool::lastRollingFeeUpdate
int64_t lastRollingFeeUpdate
Definition: txmempool.h:488
TxMempoolInfo::nFeeDelta
int64_t nFeeDelta
The fee delta.
Definition: txmempool.h:389
RecursiveDynamicUsage
static size_t RecursiveDynamicUsage(const CScript &script)
Definition: core_memusage.h:12
CTxMemPoolEntry::GetModFeesWithAncestors
CAmount GetModFeesWithAncestors() const
Definition: txmempool.h:152
entry_time
Definition: txmempool.h:365
CTxMemPool::cs
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition: txmempool.h:565
CTxMemPool::GetAndIncrementSequence
uint64_t GetAndIncrementSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Guards this internal counter for external reporting.
Definition: txmempool.h:785
LockPoints::LockPoints
LockPoints()
Definition: txmempool.h:51
CTxMemPool::get
CTransactionRef get(const uint256 &hash) const
Definition: txmempool.cpp:822
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:901
CTxMemPoolEntry::GetSigOpCost
int64_t GetSigOpCost() const
Definition: txmempool.h:129
CompareTxMemPoolEntryByEntryTime
Definition: txmempool.h:310
CTxMemPool::nTransactionsUpdated
std::atomic< unsigned int > nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
Definition: txmempool.h:481
CTxMemPoolEntry::nModFeesWithAncestors
CAmount nModFeesWithAncestors
Definition: txmempool.h:113
update_descendant_state
Definition: txmempool.h:165
Coin
A UTXO entry.
Definition: coins.h:32
Epoch::Marker
Definition: epochguard.h:46
CTxMemPool::mapDeltas
std::map< uint256, CAmount > mapDeltas
Definition: txmempool.h:590
mempoolentry_wtxid::result_type
uint256 result_type
Definition: txmempool.h:234
CTxMemPool::UpdateChild
void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:986
CTxMemPoolEntry::UpdateAncestorState
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps)
Definition: txmempool.cpp:324
CTxMemPool::GetTotalFee
CAmount GetTotalFee() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:730
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:911
SaltedTxidHasher
Definition: hasher.h:12
CompareTxMemPoolEntryByDescendantScore::GetModFeeAndSize
void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee, double &size) const
Definition: txmempool.h:272
update_fee_delta::update_fee_delta
update_fee_delta(int64_t _feeDelta)
Definition: txmempool.h:198
CTxMemPool::m_sequence_number
uint64_t m_sequence_number
Definition: txmempool.h:496
CTxMemPoolEntry::UpdateDescendantState
void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount)
Definition: txmempool.cpp:315
update_ancestor_state::modifySigOpsCost
int64_t modifySigOpsCost
Definition: txmempool.h:193
CBlockPolicyEstimator
Definition: fees.h:131
update_descendant_state::modifyFee
CAmount modifyFee
Definition: txmempool.h:176
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:907
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:546
CTxMemPool::m_check_ratio
const int m_check_ratio
Value n means that 1 times in n we check.
Definition: txmempool.h:480
CTxMemPool::UpdateParent
void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:997
AssertLockHeld
#define AssertLockHeld(cs)
Definition: sync.h:81
CTxMemPool::RemoveUnbroadcastTx
void RemoveUnbroadcastTx(const uint256 &txid, const bool unchecked=false)
Removes a transaction from the unbroadcast set.
Definition: txmempool.cpp:943
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:108
uint256
256-bit opaque blob.
Definition: uint256.h:124
CTxMemPoolEntry::nFee
const CAmount nFee
Cached to avoid expensive parent-transaction lookups.
Definition: txmempool.h:93
MemPoolRemovalReason::REPLACED
@ REPLACED
Removed for replacement.
CompareIteratorByHash::operator()
bool operator()(const T &a, const T &b) const
Definition: txmempool.h:63
CTxMemPool::minerPolicyEstimator
CBlockPolicyEstimator * minerPolicyEstimator
Definition: txmempool.h:482
CChainState
CChainState stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:538
CompareTxMemPoolEntryByScore
Definition: txmempool.h:296
CTxMemPoolEntry::UpdateFeeDelta
void UpdateFeeDelta(int64_t feeDelta)
Definition: txmempool.cpp:41
CCoinsViewMemPool::GetCoin
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: txmempool.cpp:921
coins.h
CompareIteratorByHash::operator()
bool operator()(const std::reference_wrapper< T > &a, const std::reference_wrapper< T > &b) const
Definition: txmempool.h:58
DisconnectedBlockTransactions::clear
void clear()
Definition: txmempool.h:957
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:894
CTxMemPoolEntry::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.h:131
ancestor_score
Definition: txmempool.h:366
DisconnectedBlockTransactions::removeForBlock
void removeForBlock(const std::vector< CTransactionRef > &vtx)
Definition: txmempool.h:935
mempoolentry_txid::operator()
result_type operator()(const CTxMemPoolEntry &entry) const
Definition: txmempool.h:220
hasher.h
index_by_wtxid
Definition: txmempool.h:367
CTxMemPool::PrioritiseTransaction
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
Definition: txmempool.cpp:842
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:255
CTxMemPoolEntry::GetMemPoolChildrenConst
const Children & GetMemPoolChildrenConst() const
Definition: txmempool.h:156
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:960
CTxMemPoolEntry::tx
const CTransactionRef tx
Definition: txmempool.h:90
update_ancestor_state::update_ancestor_state
update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost)
Definition: txmempool.h:182
CTxMemPool::LOCKS_EXCLUDED
void cs_main LOCKS_EXCLUDED(m_epoch)
CTxMemPool::exists
bool exists(const GenTxid &gtxid) const
Definition: txmempool.h:736
DisconnectedBlockTransactions
Definition: txmempool.h:892
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:218
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:778
CTxMemPool::exists
bool exists(const uint256 &txid) const
Definition: txmempool.h:744
CCoinsViewBacked
CCoinsView backed by another CCoinsView.
Definition: coins.h:196
CTxMemPoolEntry::GetLockPoints
const LockPoints & GetLockPoints() const
Definition: txmempool.h:132
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:617
CompareTxMemPoolEntryByDescendantScore
Definition: txmempool.h:251
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:346
DisconnectedBlockTransactions::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.h:924
CTxMemPoolEntry
Definition: txmempool.h:81
LOCK
#define LOCK(cs)
Definition: sync.h:232
MemPoolRemovalReason
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:395
DisconnectedBlockTransactions::queuedTx
indexed_disconnected_transactions queuedTx
Definition: txmempool.h:919
CTxMemPool::infoAll
std::vector< TxMempoolInfo > infoAll() const
Definition: txmempool.cpp:808
CTxMemPool::blockSinceLastRollingFeeBump
bool blockSinceLastRollingFeeBump
Definition: txmempool.h:489
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:888
CompareTxMemPoolEntryByAncestorFee::operator()
bool operator()(const T &a, const T &b) const
Definition: txmempool.h:327
update_descendant_state::update_descendant_state
update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount)
Definition: txmempool.h:167
LockPoints
Definition: txmempool.h:39
mempoolentry_txid
Definition: txmempool.h:217
CTxMemPool::trackPackageRemoved
void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1032
CTxMemPool::rollingMinimumFeeRate
double rollingMinimumFeeRate
minimum fee to get into the pool, decreases exponentially
Definition: txmempool.h:490
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:952
CCoinsViewMemPool
CCoinsView that brings transactions from a mempool into view.
Definition: txmempool.h:863
CTxMemPool::size
unsigned long size() const
Definition: txmempool.h:718
CTxMemPoolEntry::CTxMemPoolEntry
CTxMemPoolEntry(const CTransactionRef &_tx, const CAmount &_nFee, int64_t _nTime, unsigned int _entryHeight, bool spendsCoinbase, int64_t nSigOpsCost, LockPoints lp)
Definition: txmempool.cpp:23
TxMempoolInfo
Information about a mempool transaction.
Definition: txmempool.h:374
CTxMemPoolEntry::UpdateLockPoints
void UpdateLockPoints(const LockPoints &lp)
Definition: txmempool.cpp:48
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:254
CTxMemPool::CompareDepthAndScore
bool CompareDepthAndScore(const uint256 &hasha, const uint256 &hashb, bool wtxid=false)
Definition: txmempool.cpp:746
CTxMemPoolEntry::GetModFeesWithDescendants
CAmount GetModFeesWithDescendants() const
Definition: txmempool.h:146
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:37
update_ancestor_state::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:186
update_fee_delta::feeDelta
int64_t feeDelta
Definition: txmempool.h:203
CTransaction::GetWitnessHash
const uint256 & GetWitnessHash() const
Definition: transaction.h:303
CTxMemPool::info
TxMempoolInfo info(const uint256 &hash) const
Definition: txmempool.cpp:840
update_ancestor_state::modifySize
int64_t modifySize
Definition: txmempool.h:190
CTxMemPool::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.cpp:937
CTxMemPoolEntry::GetTxSize
size_t GetTxSize() const
Definition: txmempool.cpp:53
CTxMemPoolEntry::GetTxWeight
size_t GetTxWeight() const
Definition: txmempool.h:126
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:191
CTxMemPoolEntry::GetMemPoolChildren
Children & GetMemPoolChildren() const
Definition: txmempool.h:158
MemPoolRemovalReason::BLOCK
@ BLOCK
Removed for block.
mempoolentry_txid::result_type
uint256 result_type
Definition: txmempool.h:219
TxMempoolInfo::m_time
std::chrono::seconds m_time
Time the transaction entered the mempool.
Definition: txmempool.h:380
CTxMemPool::GetTotalTxSize
uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:724
CTxMemPoolEntry::GetSizeWithAncestors
uint64_t GetSizeWithAncestors() const
Definition: txmempool.h:151
TxMempoolInfo::fee
CAmount fee
Fee of the transaction.
Definition: txmempool.h:383
CTxMemPoolEntry::GetCountWithDescendants
uint64_t GetCountWithDescendants() const
Definition: txmempool.h:144
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:137
CTxMemPoolEntry::entryHeight
const unsigned int entryHeight
Chain height when entering the mempool.
Definition: txmempool.h:97
CTxMemPool::cacheMap
std::map< txiter, setEntries, CompareIteratorByHash > cacheMap
Definition: txmempool.h:575
CTxMemPool::isSpent
bool isSpent(const COutPoint &outpoint) const
Definition: txmempool.cpp:341
amount.h
CTxMemPoolEntry::sigOpCost
const int64_t sigOpCost
Total sigop cost.
Definition: txmempool.h:99
CTxMemPoolEntry::CTxMemPoolEntryRef
std::reference_wrapper< const CTxMemPoolEntry > CTxMemPoolEntryRef
Definition: txmempool.h:84
CTxMemPool::clear
void clear()
Definition: txmempool.cpp:608
CompareTxMemPoolEntryByEntryTime::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:313
CTxMemPool::_clear
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:595
assert
assert(std::addressof(::ChainstateActive().CoinsTip())==std::addressof(coins_cache))
mempoolentry_wtxid::operator()
result_type operator()(const CTxMemPoolEntry &entry) const
Definition: txmempool.h:235
CTxMemPoolEntry::GetSizeWithDescendants
uint64_t GetSizeWithDescendants() const
Definition: txmempool.h:145
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:208
update_fee_delta::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:200
DisconnectedBlockTransactions::cachedInnerUsage
uint64_t cachedInnerUsage
Definition: txmempool.h:920
Epoch
Epoch: RAII-style guard for using epoch-based graph traversal algorithms.
Definition: epochguard.h:33
CTxMemPoolEntry::m_epoch_marker
Epoch::Marker m_epoch_marker
epoch when last touched, useful for graph algorithms
Definition: txmempool.h:161
it
auto it
Definition: validation.cpp:398
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:566
CTxMemPool::removeForReorg
void removeForReorg(CChainState &active_chainstate, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs
Definition: txmempool.cpp:507
CTxMemPool::removeRecursive
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:477
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:130
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:453
CTxMemPoolEntry::GetTx
const CTransaction & GetTx() const
Definition: txmempool.h:122