Bitcoin ABC  0.24.7
P2P Digital Currency
txmempool.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_TXMEMPOOL_H
7 #define BITCOIN_TXMEMPOOL_H
8 
9 #include <amount.h>
10 #include <coins.h>
11 #include <core_memusage.h>
12 #include <indirectmap.h>
13 #include <primitives/transaction.h>
14 #include <salteduint256hasher.h>
15 #include <sync.h>
16 
17 #include <boost/multi_index/hashed_index.hpp>
18 #include <boost/multi_index/ordered_index.hpp>
19 #include <boost/multi_index/sequenced_index.hpp>
20 #include <boost/multi_index_container.hpp>
21 
22 #include <atomic>
23 #include <map>
24 #include <optional>
25 #include <set>
26 #include <string>
27 #include <utility>
28 #include <vector>
29 
30 class CBlockIndex;
31 class Config;
32 
33 extern RecursiveMutex cs_main;
34 
39 static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
40 
41 struct LockPoints {
42  // Will be set to the blockchain height and median time past values that
43  // would be necessary to satisfy all relative locktime constraints (BIP68)
44  // of this tx given our view of block chain history
45  int height;
46  int64_t time;
47  // As long as the current chain descends from the highest height block
48  // containing one of the inputs used in the calculation, then the cached
49  // values are still valid even after a reorg.
51 
52  LockPoints() : height(0), time(0), maxInputBlock(nullptr) {}
53 };
54 
56  // SFINAE for T where T is either a pointer type (e.g., a txiter) or a
57  // reference_wrapper<T> (e.g. a wrapped CTxMemPoolEntry&)
58  template <typename T>
59  bool operator()(const std::reference_wrapper<T> &a,
60  const std::reference_wrapper<T> &b) const {
61  return a.get().GetTx().GetId() < b.get().GetTx().GetId();
62  }
63  template <typename T> bool operator()(const T &a, const T &b) const {
64  return a->GetTx().GetId() < b->GetTx().GetId();
65  }
66 };
67 
80 public:
81  typedef std::reference_wrapper<const CTxMemPoolEntry> CTxMemPoolEntryRef;
82  // two aliases, should the types ever diverge
83  typedef std::set<CTxMemPoolEntryRef, CompareIteratorById> Parents;
84  typedef std::set<CTxMemPoolEntryRef, CompareIteratorById> Children;
85 
86 private:
88  mutable Parents m_parents;
91  const Amount nFee;
93  const size_t nTxSize;
95  const size_t nUsageSize;
97  const int64_t nTime;
99  const unsigned int entryHeight;
101  const bool spendsCoinbase;
108  const int64_t sigOpCount;
114 
115  // Information about descendants of this transaction that are in the
116  // mempool; if we remove this transaction we must remove all of these
117  // descendants as well.
126 
127  // Analogous statistics for ancestor transactions
132 
133 public:
134  CTxMemPoolEntry(const CTransactionRef &_tx, const Amount _nFee,
135  int64_t _nTime, unsigned int _entryHeight,
136  bool spendsCoinbase, int64_t _nSigOpCount, LockPoints lp);
137 
138  const CTransaction &GetTx() const { return *this->tx; }
139  CTransactionRef GetSharedTx() const { return this->tx; }
140  const Amount GetFee() const { return nFee; }
141  size_t GetTxSize() const { return nTxSize; }
142  size_t GetTxVirtualSize() const;
143 
144  std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
145  unsigned int GetHeight() const { return entryHeight; }
146  int64_t GetSigOpCount() const { return sigOpCount; }
147  Amount GetModifiedFee() const { return nFee + feeDelta; }
148  size_t DynamicMemoryUsage() const { return nUsageSize; }
149  const LockPoints &GetLockPoints() const { return lockPoints; }
150 
151  // Adjusts the descendant state.
152  void UpdateDescendantState(int64_t modifySize, Amount modifyFee,
153  int64_t modifyCount, int64_t modifySigOpCount);
154  // Adjusts the ancestor state
155  void UpdateAncestorState(int64_t modifySize, Amount modifyFee,
156  int64_t modifyCount, int64_t modifySigOps);
157  // Updates the fee delta used for mining priority score, and the
158  // modified fees with descendants.
160  // Update the LockPoints after a reorg
161  void UpdateLockPoints(const LockPoints &lp);
162 
163  uint64_t GetCountWithDescendants() const { return nCountWithDescendants; }
164  uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
165  uint64_t GetVirtualSizeWithDescendants() const;
169  }
170 
171  bool GetSpendsCoinbase() const { return spendsCoinbase; }
172 
173  uint64_t GetCountWithAncestors() const { return nCountWithAncestors; }
174  uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
175  uint64_t GetVirtualSizeWithAncestors() const;
177  int64_t GetSigOpCountWithAncestors() const {
179  }
180 
181  const Parents &GetMemPoolParentsConst() const { return m_parents; }
182  const Children &GetMemPoolChildrenConst() const { return m_children; }
183  Parents &GetMemPoolParents() const { return m_parents; }
185 
187  mutable size_t vTxHashesIdx;
189  mutable uint64_t m_epoch;
190 };
191 
192 // Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index.
194  update_descendant_state(int64_t _modifySize, Amount _modifyFee,
195  int64_t _modifyCount, int64_t _modifySigOpCount)
196  : modifySize(_modifySize), modifyFee(_modifyFee),
197  modifyCount(_modifyCount), modifySigOpCount(_modifySigOpCount) {}
198 
202  }
203 
204 private:
205  int64_t modifySize;
207  int64_t modifyCount;
209 };
210 
212  update_ancestor_state(int64_t _modifySize, Amount _modifyFee,
213  int64_t _modifyCount, int64_t _modifySigOpCount)
214  : modifySize(_modifySize), modifyFee(_modifyFee),
215  modifyCount(_modifyCount), modifySigOpCount(_modifySigOpCount) {}
216 
220  }
221 
222 private:
223  int64_t modifySize;
225  int64_t modifyCount;
227 };
228 
230  explicit update_fee_delta(Amount _feeDelta) : feeDelta(_feeDelta) {}
231 
233 
234 private:
236 };
237 
239  explicit update_lock_points(const LockPoints &_lp) : lp(_lp) {}
240 
242 
243 private:
244  const LockPoints &lp;
245 };
246 
247 // extracts a transaction id from CTxMemPoolEntry or CTransactionRef
249  typedef TxId result_type;
250  result_type operator()(const CTxMemPoolEntry &entry) const {
251  return entry.GetTx().GetId();
252  }
253 
255  return tx->GetId();
256  }
257 };
258 
265 public:
266  bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const {
267  double a_mod_fee, a_size, b_mod_fee, b_size;
268 
269  GetModFeeAndSize(a, a_mod_fee, a_size);
270  GetModFeeAndSize(b, b_mod_fee, b_size);
271 
272  // Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
273  double f1 = a_mod_fee * b_size;
274  double f2 = a_size * b_mod_fee;
275 
276  if (f1 == f2) {
277  return a.GetTime() >= b.GetTime();
278  }
279  return f1 < f2;
280  }
281 
282  // Return the fee/size we're using for sorting this entry.
283  void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee,
284  double &size) const {
285  // Compare feerate with descendants to feerate of the transaction, and
286  // return the fee/size for the max.
287  double f1 =
289  double f2 =
291 
292  if (f2 > f1) {
293  mod_fee = a.GetModFeesWithDescendants() / SATOSHI;
295  } else {
296  mod_fee = a.GetModifiedFee() / SATOSHI;
297  size = a.GetTxVirtualSize();
298  }
299  }
300 };
301 
310 public:
311  bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const {
312  double f1 = b.GetTxSize() * (a.GetFee() / SATOSHI);
313  double f2 = a.GetTxSize() * (b.GetFee() / SATOSHI);
314  if (f1 == f2) {
315  return b.GetTx().GetId() < a.GetTx().GetId();
316  }
317  return f1 > f2;
318  }
319 };
320 
322 public:
323  bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const {
324  return a.GetTime() < b.GetTime();
325  }
326 };
327 
334 public:
335  template <typename T> bool operator()(const T &a, const T &b) const {
336  double a_mod_fee, a_size, b_mod_fee, b_size;
337 
338  GetModFeeAndSize(a, a_mod_fee, a_size);
339  GetModFeeAndSize(b, b_mod_fee, b_size);
340 
341  // Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
342  double f1 = a_mod_fee * b_size;
343  double f2 = a_size * b_mod_fee;
344 
345  if (f1 == f2) {
346  return a.GetTx().GetId() < b.GetTx().GetId();
347  }
348  return f1 > f2;
349  }
350 
351  // Return the fee/size we're using for sorting this entry.
352  template <typename T>
353  void GetModFeeAndSize(const T &a, double &mod_fee, double &size) const {
354  // Compare feerate with ancestors to feerate of the transaction, and
355  // return the fee/size for the min.
356  double f1 =
357  a.GetVirtualSizeWithAncestors() * (a.GetModifiedFee() / SATOSHI);
358  double f2 =
359  a.GetTxVirtualSize() * (a.GetModFeesWithAncestors() / SATOSHI);
360 
361  if (f1 > f2) {
362  mod_fee = a.GetModFeesWithAncestors() / SATOSHI;
363  size = a.GetVirtualSizeWithAncestors();
364  } else {
365  mod_fee = a.GetModifiedFee() / SATOSHI;
366  size = a.GetTxVirtualSize();
367  }
368  }
369 };
370 
371 // Multi_index tag names
373 struct entry_time {};
374 struct ancestor_score {};
375 
382 
384  std::chrono::seconds m_time;
385 
388 
390  size_t vsize;
391 
394 };
395 
402  EXPIRY,
404  SIZELIMIT,
406  REORG,
408  BLOCK,
410  CONFLICT,
412  REPLACED
413 };
414 
416 public:
418 
419  size_t operator()(const TxId &txid) const { return hash(txid); }
420 };
421 
495 class CTxMemPool {
496 private:
498  uint32_t nCheckFrequency GUARDED_BY(cs);
500  std::atomic<uint32_t> nTransactionsUpdated;
501 
503  uint64_t totalTxSize;
507 
508  mutable int64_t lastRollingFeeUpdate;
511  mutable double rollingMinimumFeeRate;
512  mutable uint64_t m_epoch;
513  mutable bool m_has_epoch_guard;
514 
515  // In-memory counter for external mempool tracking purposes.
516  // This number is incremented once every time a transaction
517  // is added or removed from the mempool for any reason.
518  mutable uint64_t m_sequence_number{1};
519 
521 
522  bool m_is_loaded GUARDED_BY(cs){false};
523 
524 public:
525  // public only for testing
526  static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12;
527 
528  typedef boost::multi_index_container<
529  CTxMemPoolEntry, boost::multi_index::indexed_by<
530  // sorted by txid
531  boost::multi_index::hashed_unique<
533  // sorted by fee rate
534  boost::multi_index::ordered_non_unique<
535  boost::multi_index::tag<descendant_score>,
536  boost::multi_index::identity<CTxMemPoolEntry>,
538  // sorted by entry time
539  boost::multi_index::ordered_non_unique<
540  boost::multi_index::tag<entry_time>,
541  boost::multi_index::identity<CTxMemPoolEntry>,
543  // sorted by fee rate with ancestors
544  boost::multi_index::ordered_non_unique<
545  boost::multi_index::tag<ancestor_score>,
546  boost::multi_index::identity<CTxMemPoolEntry>,
549 
579 
580  using txiter = indexed_transaction_set::nth_index<0>::type::const_iterator;
582  std::vector<std::pair<TxHash, txiter>> vTxHashes GUARDED_BY(cs);
583 
584  typedef std::set<txiter, CompareIteratorById> setEntries;
585 
586  uint64_t CalculateDescendantMaximum(txiter entry) const
588 
589 private:
590  typedef std::map<txiter, setEntries, CompareIteratorById> cacheMap;
591 
592  void UpdateParent(txiter entry, txiter parent, bool add)
594  void UpdateChild(txiter entry, txiter child, bool add)
596 
597  std::vector<indexed_transaction_set::const_iterator>
599 
604  std::set<TxId> m_unbroadcast_txids GUARDED_BY(cs);
605 
606 public:
607  indirectmap<COutPoint, const CTransaction *> mapNextTx GUARDED_BY(cs);
608  std::map<TxId, Amount> mapDeltas;
609 
613  CTxMemPool();
614  ~CTxMemPool();
615 
622  void check(const CCoinsViewCache *pcoins) const;
623  void setSanityCheck(double dFrequency = 1.0) {
624  LOCK(cs);
625  nCheckFrequency = static_cast<uint32_t>(dFrequency * 4294967295.0);
626  }
627 
628  // addUnchecked must updated state for all ancestors of a given transaction,
629  // to track size/count of descendant transactions. First version of
630  // addUnchecked can be used to have it call CalculateMemPoolAncestors(), and
631  // then invoke the second version.
632  // Note that addUnchecked is ONLY called from ATMP outside of tests
633  // and any other callers may break wallet's in-mempool tracking (due to
634  // lack of CValidationInterface::TransactionAddedToMempool callbacks).
635  void addUnchecked(const CTxMemPoolEntry &entry)
637  void addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAncestors)
639 
640  void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason)
642  void removeForReorg(const Config &config, const CCoinsViewCache *pcoins,
643  unsigned int nMemPoolHeight, int flags)
646  void removeForBlock(const std::vector<CTransactionRef> &vtx,
647  unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
648 
649  void clear();
650  // lock free
652  bool CompareDepthAndScore(const TxId &txida, const TxId &txidb);
653  void queryHashes(std::vector<uint256> &vtxid) const;
654  bool isSpent(const COutPoint &outpoint) const;
655  unsigned int GetTransactionsUpdated() const;
656  void AddTransactionsUpdated(unsigned int n);
662  bool HasNoInputsOf(const CTransaction &tx) const
664 
666  void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta);
667  void ApplyDelta(const TxId &txid, Amount &nFeeDelta) const
670 
672  const CTransaction *GetConflictTx(const COutPoint &prevout) const
674 
676  std::optional<txiter> GetIter(const TxId &txid) const
678 
683  setEntries GetIterSet(const std::set<TxId> &txids) const
685 
693  void RemoveStaged(setEntries &stage, bool updateDescendants,
695 
707  void UpdateTransactionsFromBlock(const std::vector<TxId> &txidsToUpdate)
709 
723  const CTxMemPoolEntry &entry, setEntries &setAncestors,
724  uint64_t limitAncestorCount, uint64_t limitAncestorSize,
725  uint64_t limitDescendantCount, uint64_t limitDescendantSize,
726  std::string &errString, bool fSearchForParents = true) const
728 
734  void CalculateDescendants(txiter it, setEntries &setDescendants) const
736 
744  CFeeRate GetMinFee(size_t sizelimit) const;
745 
752  void TrimToSize(size_t sizelimit,
753  std::vector<COutPoint> *pvNoSpendsRemaining = nullptr)
755 
760  int Expire(std::chrono::seconds time) EXCLUSIVE_LOCKS_REQUIRED(cs);
761 
765  void LimitSize(size_t limit, std::chrono::seconds age)
767 
772  void GetTransactionAncestry(const TxId &txid, size_t &ancestors,
773  size_t &descendants) const;
774 
776  bool IsLoaded() const;
777 
779  void SetIsLoaded(bool loaded);
780 
781  unsigned long size() const {
782  LOCK(cs);
783  return mapTx.size();
784  }
785 
788  return totalTxSize;
789  }
790 
791  bool exists(const TxId &txid) const {
792  LOCK(cs);
793  return mapTx.count(txid) != 0;
794  }
795 
796  CTransactionRef get(const TxId &txid) const;
797  TxMempoolInfo info(const TxId &txid) const;
798  std::vector<TxMempoolInfo> infoAll() const;
799 
800  CFeeRate estimateFee() const;
801 
802  size_t DynamicMemoryUsage() const;
803 
805  void AddUnbroadcastTx(const TxId &txid) {
806  LOCK(cs);
807  // Sanity Check: the transaction should also be in the mempool
808  if (exists(txid)) {
809  m_unbroadcast_txids.insert(txid);
810  }
811  }
812 
814  void RemoveUnbroadcastTx(const TxId &txid, const bool unchecked = false);
815 
817  std::set<TxId> GetUnbroadcastTxs() const {
818  LOCK(cs);
819  return m_unbroadcast_txids;
820  }
821 
823  bool IsUnbroadcastTx(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs) {
825  return (m_unbroadcast_txids.count(txid) != 0);
826  }
827 
830  return m_sequence_number++;
831  }
832 
834  return m_sequence_number;
835  }
836 
837 private:
851  void UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendants,
852  const std::set<TxId> &setExclude)
857  void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors)
860  void UpdateEntryForAncestors(txiter it, const setEntries &setAncestors)
867  void UpdateForRemoveFromMempool(const setEntries &entriesToRemove,
868  bool updateDescendants)
872 
881  void removeUnchecked(txiter entry, MemPoolRemovalReason reason)
883 
884 public:
905  class EpochGuard {
906  const CTxMemPool &pool;
907 
908  public:
909  EpochGuard(const CTxMemPool &in);
910  ~EpochGuard();
911  };
912  // N.B. GetFreshEpoch modifies mutable state via the EpochGuard construction
913  // (and later destruction)
915 
926  assert(m_has_epoch_guard);
927  bool ret = it->m_epoch >= m_epoch;
928  it->m_epoch = std::max(it->m_epoch, m_epoch);
929  return ret;
930  }
931 
932  bool visited(std::optional<txiter> it) const EXCLUSIVE_LOCKS_REQUIRED(cs) {
933  assert(m_has_epoch_guard);
934  return !it || visited(*it);
935  }
936 };
937 
951 protected:
953 
954 public:
955  CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn);
956  bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
957 };
958 
977 // multi_index tag names
978 struct txid_index {};
979 struct insertion_order {};
980 
982 private:
983  typedef boost::multi_index_container<
984  CTransactionRef, boost::multi_index::indexed_by<
985  // sorted by txid
986  boost::multi_index::hashed_unique<
987  boost::multi_index::tag<txid_index>,
989  // sorted by order in the blockchain
990  boost::multi_index::sequenced<
991  boost::multi_index::tag<insertion_order>>>>
993 
995  uint64_t cachedInnerUsage = 0;
996 
997  void addTransaction(const CTransactionRef &tx) {
998  queuedTx.insert(tx);
1000  }
1001 
1002 public:
1003  // It's almost certainly a logic bug if we don't clear out queuedTx before
1004  // destruction, as we add to it while disconnecting blocks, and then we
1005  // need to re-process remaining transactions to ensure mempool consistency.
1006  // For now, assert() that we've emptied out this object on destruction.
1007  // This assert() can always be removed if the reorg-processing code were
1008  // to be refactored such that this assumption is no longer true (for
1009  // instance if there was some other way we cleaned up the mempool after a
1010  // reorg, besides draining this object).
1012 
1013  // Estimate the overhead of queuedTx to be 6 pointers + an allocation, as
1014  // no exact formula for boost::multi_index_contained is implemented.
1015  size_t DynamicMemoryUsage() const {
1016  return memusage::MallocUsage(sizeof(CTransactionRef) +
1017  6 * sizeof(void *)) *
1018  queuedTx.size() +
1020  }
1021 
1023  return queuedTx;
1024  }
1025 
1026  // Import mempool entries in topological order into queuedTx and clear the
1027  // mempool. Caller should call updateMempoolForReorg to reprocess these
1028  // transactions
1029  void importMempool(CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
1030 
1031  // Add entries for a block while reconstructing the topological ordering so
1032  // they can be added back to the mempool simply.
1033  void addForBlock(const std::vector<CTransactionRef> &vtx, CTxMemPool &pool)
1034  EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
1035 
1036  // Remove entries based on txid_index, and update memory usage.
1037  void removeForBlock(const std::vector<CTransactionRef> &vtx) {
1038  // Short-circuit in the common case of a block being added to the tip
1039  if (queuedTx.empty()) {
1040  return;
1041  }
1042  for (auto const &tx : vtx) {
1043  auto it = queuedTx.find(tx->GetId());
1044  if (it != queuedTx.end()) {
1046  queuedTx.erase(it);
1047  }
1048  }
1049  }
1050 
1051  // Remove an entry by insertion_order index, and update memory usage.
1052  void removeEntry(indexed_disconnected_transactions::index<
1053  insertion_order>::type::iterator entry) {
1055  queuedTx.get<insertion_order>().erase(entry);
1056  }
1057 
1058  bool isEmpty() const { return queuedTx.empty(); }
1059 
1060  void clear() {
1061  cachedInnerUsage = 0;
1062  queuedTx.clear();
1063  }
1064 
1078  void updateMempoolForReorg(const Config &config, bool fAddToMempool,
1079  CTxMemPool &pool)
1081 };
1082 
1083 #endif // BITCOIN_TXMEMPOOL_H
CTxMemPoolEntry::GetTxVirtualSize
size_t GetTxVirtualSize() const
Definition: txmempool.cpp:49
CTxMemPool::GetIterSet
setEntries GetIterSet(const std::set< TxId > &txids) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Translate a set of txids into a set of pool iterators to avoid repeated lookups.
Definition: txmempool.cpp:1036
CTxMemPoolEntry::GetSpendsCoinbase
bool GetSpendsCoinbase() const
Definition: txmempool.h:171
CTxMemPoolEntry::nCountWithDescendants
uint64_t nCountWithDescendants
number of descendant transactions
Definition: txmempool.h:119
CTxMemPool::AddTransactionsUpdated
void AddTransactionsUpdated(unsigned int n)
Definition: txmempool.cpp:424
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:1171
SaltedUint256Hasher
Definition: salteduint256hasher.h:11
mempoolentry_txid::result_type
TxId result_type
Definition: txmempool.h:249
CTxMemPool::EpochGuard::EpochGuard
EpochGuard(const CTxMemPool &in)
Definition: txmempool.cpp:1452
CompareIteratorById
Definition: txmempool.h:55
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:475
update_fee_delta
Definition: txmempool.h:229
CTxMemPoolEntry::GetHeight
unsigned int GetHeight() const
Definition: txmempool.h:145
update_fee_delta::feeDelta
Amount feeDelta
Definition: txmempool.h:235
CTxMemPoolEntry::nModFeesWithAncestors
Amount nModFeesWithAncestors
Definition: txmempool.h:130
CTxMemPool::GUARDED_BY
uint32_t nCheckFrequency GUARDED_BY(cs)
Value n means that n times in 2^32 we check.
CTxMemPoolEntry::GetModFeesWithDescendants
Amount GetModFeesWithDescendants() const
Definition: txmempool.h:166
CTxMemPoolEntry::nCountWithAncestors
uint64_t nCountWithAncestors
Definition: txmempool.h:128
CTxMemPool::ROLLING_FEE_HALFLIFE
static const int ROLLING_FEE_HALFLIFE
Definition: txmempool.h:526
TxMempoolInfo::vsize
size_t vsize
Virtual size of the transaction.
Definition: txmempool.h:390
CTxMemPoolEntry::nTime
const int64_t nTime
Local time when entering the mempool.
Definition: txmempool.h:97
flags
int flags
Definition: bitcoin-tx.cpp:532
txid_index
DisconnectedBlockTransactions.
Definition: txmempool.h:978
CTxMemPool::EpochGuard::~EpochGuard
~EpochGuard()
Definition: txmempool.cpp:1458
CompareTxMemPoolEntryByScore::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:311
CTxMemPool::removeForReorg
void removeForReorg(const Config &config, const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs
Definition: txmempool.cpp:579
CTxMemPoolEntry::lockPoints
LockPoints lockPoints
Track the height and time at which tx was final.
Definition: txmempool.h:113
update_lock_points
Definition: txmempool.h:238
CTxMemPool::GetSortedDepthAndScore
std::vector< indexed_transaction_set::const_iterator > GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:895
mempoolentry_txid::operator()
result_type operator()(const CTransactionRef &tx) const
Definition: txmempool.h:254
CTxMemPoolEntry::Children
std::set< CTxMemPoolEntryRef, CompareIteratorById > Children
Definition: txmempool.h:84
sync.h
DisconnectedBlockTransactions::removeForBlock
void removeForBlock(const std::vector< CTransactionRef > &vtx)
Definition: txmempool.h:1037
update_descendant_state::modifyCount
int64_t modifyCount
Definition: txmempool.h:207
transaction.h
CTxMemPool::cs_main
void cs_main
Definition: txmempool.h:636
CTxMemPool::txiter
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
Definition: txmempool.h:580
CTxMemPool::IsLoaded
bool IsLoaded() const
Definition: txmempool.cpp:1291
CTxMemPoolEntry::feeDelta
Amount feeDelta
Used for determining the priority of the transaction for mining in a block.
Definition: txmempool.h:111
CompareIteratorById::operator()
bool operator()(const std::reference_wrapper< T > &a, const std::reference_wrapper< T > &b) const
Definition: txmempool.h:59
indirectmap
Map whose keys are pointers, but are compared by their dereferenced values.
Definition: indirectmap.h:26
CompareIteratorById::operator()
bool operator()(const T &a, const T &b) const
Definition: txmempool.h:63
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:495
CTxMemPoolEntry::spendsCoinbase
const bool spendsCoinbase
keep track of transactions that spend a coinbase
Definition: txmempool.h:101
LockPoints::time
int64_t time
Definition: txmempool.h:46
CTxMemPool::estimateFee
CFeeRate estimateFee() const
Definition: txmempool.cpp:960
CompareTxMemPoolEntryByAncestorFee
Definition: txmempool.h:333
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:1202
CTxMemPoolEntry::m_parents
Parents m_parents
Definition: txmempool.h:88
CTxMemPoolEntry::GetTime
std::chrono::seconds GetTime() const
Definition: txmempool.h:144
CTxMemPoolEntry::GetSharedTx
CTransactionRef GetSharedTx() const
Definition: txmempool.h:139
CTxMemPoolEntry::GetSigOpCountWithDescendants
int64_t GetSigOpCountWithDescendants() const
Definition: txmempool.h:167
CTxMemPoolEntry::GetMemPoolParentsConst
const Parents & GetMemPoolParentsConst() const
Definition: txmempool.h:181
CTxMemPool::SetIsLoaded
void SetIsLoaded(bool loaded)
Sets the current loaded state.
Definition: txmempool.cpp:1296
descendant_score
Definition: txmempool.h:372
MemPoolRemovalReason::EXPIRY
@ EXPIRY
Expired from mempool.
CTxMemPoolEntry::GetMemPoolParents
Parents & GetMemPoolParents() const
Definition: txmempool.h:183
AnnotatedMixin< std::recursive_mutex >
CTxMemPoolEntry::nModFeesWithDescendants
Amount nModFeesWithDescendants
... and total fees (all including us)
Definition: txmempool.h:123
CTxMemPool::setEntries
std::set< txiter, CompareIteratorById > setEntries
Definition: txmempool.h:584
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:244
update_lock_points::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:241
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:187
update_ancestor_state::modifyCount
int64_t modifyCount
Definition: txmempool.h:225
CTxMemPoolEntry::vTxHashesIdx
size_t vTxHashesIdx
Index in mempool's vTxHashes.
Definition: txmempool.h:187
CTxMemPoolEntry::sigOpCount
const int64_t sigOpCount
Total sigop plus P2SH sigops count.
Definition: txmempool.h:108
DisconnectedBlockTransactions::addTransaction
void addTransaction(const CTransactionRef &tx)
Definition: txmempool.h:997
CTxMemPool::GetTransactionsUpdated
unsigned int GetTransactionsUpdated() const
Definition: txmempool.cpp:420
update_descendant_state::modifyFee
Amount modifyFee
Definition: txmempool.h:206
CTxMemPool::info
TxMempoolInfo info(const TxId &txid) const
Definition: txmempool.cpp:950
CTxMemPool::visited
bool visited(txiter it) const EXCLUSIVE_LOCKS_REQUIRED(cs)
visited marks a CTxMemPoolEntry as having been traversed during the lifetime of the most recently cre...
Definition: txmempool.h:925
CTxMemPool::CalculateDescendantMaximum
uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1255
CTxMemPool::check
void check(const CCoinsViewCache *pcoins) const
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
Definition: txmempool.cpp:719
CTxMemPoolEntry::UpdateFeeDelta
void UpdateFeeDelta(Amount feeDelta)
Definition: txmempool.cpp:67
update_ancestor_state
Definition: txmempool.h:211
CTxMemPoolEntry::nSizeWithAncestors
uint64_t nSizeWithAncestors
Definition: txmempool.h:129
CTxMemPoolEntry::Parents
std::set< CTxMemPoolEntryRef, CompareIteratorById > Parents
Definition: txmempool.h:83
CCoinsViewMemPool::CCoinsViewMemPool
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn)
Definition: txmempool.cpp:1057
CTxMemPool::m_has_epoch_guard
bool m_has_epoch_guard
Definition: txmempool.h:513
CTxMemPoolEntry::nFee
const Amount nFee
Cached to avoid expensive parent-transaction lookups.
Definition: txmempool.h:91
CFeeRate
Fee rate in satoshis per kilobyte: Amount / kB.
Definition: feerate.h:21
TxMempoolInfo::tx
CTransactionRef tx
The transaction itself.
Definition: txmempool.h:381
update_descendant_state::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:199
CTxMemPoolEntry::m_children
Children m_children
Definition: txmempool.h:89
DisconnectedBlockTransactions::clear
void clear()
Definition: txmempool.h:1060
CTxMemPool::queryHashes
void queryHashes(std::vector< uint256 > &vtxid) const
Definition: txmempool.cpp:909
CTxMemPool::UpdateEntryForAncestors
void UpdateEntryForAncestors(txiter it, const setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs)
Set ancestor state for an entry.
Definition: txmempool.cpp:290
DisconnectedBlockTransactions::cachedInnerUsage
uint64_t cachedInnerUsage
Definition: txmempool.h:995
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:194
CCoinsView
Abstract view on the open txout dataset.
Definition: coins.h:175
CTxMemPoolEntry::nSizeWithDescendants
uint64_t nSizeWithDescendants
... and size
Definition: txmempool.h:121
CCoinsViewMemPool::mempool
const CTxMemPool & mempool
Definition: txmempool.h:952
CTxMemPool::GUARDED_BY
bool m_is_loaded GUARDED_BY(cs)
Definition: txmempool.h:522
CTxMemPool::PrioritiseTransaction
void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
Definition: txmempool.cpp:972
DisconnectedBlockTransactions::importMempool
void importMempool(CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
Definition: txmempool.cpp:1363
SATOSHI
static constexpr Amount SATOSHI
Definition: amount.h:153
insertion_order
Definition: txmempool.h:979
Config
Definition: config.h:17
LockPoints::maxInputBlock
CBlockIndex * maxInputBlock
Definition: txmempool.h:50
SaltedTxIdHasher::operator()
size_t operator()(const TxId &txid) const
Definition: txmempool.h:419
CTxMemPoolEntry::m_epoch
uint64_t m_epoch
epoch when last touched, useful for graph algorithms
Definition: txmempool.h:189
CTxMemPoolEntry::GetCountWithAncestors
uint64_t GetCountWithAncestors() const
Definition: txmempool.h:173
update_descendant_state::modifySize
int64_t modifySize
Definition: txmempool.h:205
CTxMemPool::lastRollingFeeUpdate
int64_t lastRollingFeeUpdate
Definition: txmempool.h:508
CTxMemPoolEntry::GetFee
const Amount GetFee() const
Definition: txmempool.h:140
RecursiveDynamicUsage
static size_t RecursiveDynamicUsage(const CScript &script)
Definition: core_memusage.h:12
entry_time
Definition: txmempool.h:373
CTxMemPool::cs
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
Definition: txmempool.h:577
CTxMemPool::GetAndIncrementSequence
uint64_t GetAndIncrementSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Guards this internal counter for external reporting.
Definition: txmempool.h:829
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::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:548
LockPoints::LockPoints
LockPoints()
Definition: txmempool.h:52
update_ancestor_state::update_ancestor_state
update_ancestor_state(int64_t _modifySize, Amount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpCount)
Definition: txmempool.h:212
CTxMemPoolEntry::nTxSize
const size_t nTxSize
... and avoid recomputing tx size
Definition: txmempool.h:93
SaltedTxIdHasher::SaltedTxIdHasher
SaltedTxIdHasher()
Definition: txmempool.h:417
TxMempoolInfo::fee
Amount fee
Fee of the transaction.
Definition: txmempool.h:387
CTxMemPool::addUnchecked
void addUnchecked(const CTxMemPoolEntry &entry) EXCLUSIVE_LOCKS_REQUIRED(cs
Definition: txmempool.cpp:1142
CompareTxMemPoolEntryByEntryTime
Definition: txmempool.h:321
update_descendant_state
Definition: txmempool.h:193
TxMempoolInfo::nFeeDelta
Amount nFeeDelta
The fee delta.
Definition: txmempool.h:393
CTransaction::GetId
const TxId GetId() const
Definition: transaction.h:244
Coin
A UTXO entry.
Definition: coins.h:27
CTxMemPool::UpdateForDescendants
void UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendants, const std::set< TxId > &setExclude) EXCLUSIVE_LOCKS_REQUIRED(cs)
UpdateForDescendants is used by UpdateTransactionsFromBlock to update the descendants for a single tr...
Definition: txmempool.cpp:80
CTxMemPool::GetIter
std::optional< txiter > GetIter(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given txid, if found.
Definition: txmempool.cpp:1027
DisconnectedBlockTransactions::queuedTx
indexed_disconnected_transactions queuedTx
Definition: txmempool.h:994
CTxMemPool::UpdateChild
void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1151
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:1047
CompareTxMemPoolEntryByDescendantScore::GetModFeeAndSize
void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee, double &size) const
Definition: txmempool.h:283
CTxMemPool::setSanityCheck
void setSanityCheck(double dFrequency=1.0)
Definition: txmempool.h:623
CTxMemPool::m_sequence_number
uint64_t m_sequence_number
Definition: txmempool.h:518
CTxMemPool::EpochGuard::pool
const CTxMemPool & pool
Definition: txmempool.h:906
CTxMemPool::visited
bool visited(std::optional< txiter > it) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:932
DisconnectedBlockTransactions::GetQueuedTx
const indexed_disconnected_transactions & GetQueuedTx() const
Definition: txmempool.h:1022
CTxMemPool::m_epoch
uint64_t m_epoch
Definition: txmempool.h:512
CTxMemPool::GetSequence
uint64_t GetSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:833
CTxMemPoolEntry::GetVirtualSizeWithAncestors
uint64_t GetVirtualSizeWithAncestors() const
Definition: txmempool.cpp:60
LockPoints::height
int height
Definition: txmempool.h:45
MemPoolRemovalReason::SIZELIMIT
@ SIZELIMIT
Removed in size limiting.
CTxMemPoolEntry::UpdateDescendantState
void UpdateDescendantState(int64_t modifySize, Amount modifyFee, int64_t modifyCount, int64_t modifySigOpCount)
Definition: txmempool.cpp:377
DisconnectedBlockTransactions::removeEntry
void removeEntry(indexed_disconnected_transactions::index< insertion_order >::type::iterator entry)
Definition: txmempool.h:1052
CTxMemPool::removeConflicts
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:633
CTxMemPool::UpdateParent
void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1161
CTxMemPool::exists
bool exists(const TxId &txid) const
Definition: txmempool.h:791
CTxMemPool::nTransactionsUpdated
std::atomic< uint32_t > nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
Definition: txmempool.h:500
uint256
256-bit opaque blob.
Definition: uint256.h:127
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:992
MemPoolRemovalReason::REPLACED
@ REPLACED
Removed for replacement.
TxId
A TxId is the identifier of a transaction.
Definition: txid.h:14
CTxMemPoolEntry::nSigOpCountWithDescendants
int64_t nSigOpCountWithDescendants
... and sigop count
Definition: txmempool.h:125
CTxMemPool::get
CTransactionRef get(const TxId &txid) const
Definition: txmempool.cpp:940
CTxMemPool::totalTxSize
uint64_t totalTxSize
sum of all mempool tx's sizes.
Definition: txmempool.h:503
CTxMemPool::cacheMap
std::map< txiter, setEntries, CompareIteratorById > cacheMap
Definition: txmempool.h:590
Amount
Definition: amount.h:19
CompareTxMemPoolEntryByScore
Definition: txmempool.h:309
CCoinsViewMemPool::GetCoin
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Definition: txmempool.cpp:1061
coins.h
CTxMemPool::mapDeltas
std::map< TxId, Amount > mapDeltas
Definition: txmempool.h:608
update_ancestor_state::modifySigOpCount
int64_t modifySigOpCount
Definition: txmempool.h:226
CTxMemPool::UpdateTransactionsFromBlock
void UpdateTransactionsFromBlock(const std::vector< TxId > &txidsToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs
When adding transactions from a disconnected block back to the mempool, new mempool entries may have ...
Definition: txmempool.cpp:137
CTxMemPoolEntry::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.h:148
ancestor_score
Definition: txmempool.h:374
CTxMemPool::ApplyDelta
void ApplyDelta(const TxId &txid, Amount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1007
mempoolentry_txid::operator()
result_type operator()(const CTxMemPoolEntry &entry) const
Definition: txmempool.h:250
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:313
CTxMemPoolEntry::GetModFeesWithAncestors
Amount GetModFeesWithAncestors() const
Definition: txmempool.h:176
CTxMemPoolEntry::GetMemPoolChildrenConst
const Children & GetMemPoolChildrenConst() const
Definition: txmempool.h:182
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:1109
CTxMemPoolEntry::tx
const CTransactionRef tx
Definition: txmempool.h:87
DisconnectedBlockTransactions::~DisconnectedBlockTransactions
~DisconnectedBlockTransactions()
Definition: txmempool.h:1011
DisconnectedBlockTransactions::isEmpty
bool isEmpty() const
Definition: txmempool.h:1058
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:272
core_memusage.h
CTxMemPool::AddUnbroadcastTx
void AddUnbroadcastTx(const TxId &txid)
Adds a transaction to the unbroadcast set.
Definition: txmempool.h:805
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:231
CTxMemPoolEntry::GetModifiedFee
Amount GetModifiedFee() const
Definition: txmempool.h:147
CCoinsViewBacked
CCoinsView backed by another CCoinsView.
Definition: coins.h:212
CTxMemPool::CompareDepthAndScore
bool CompareDepthAndScore(const TxId &txida, const TxId &txidb)
Definition: txmempool.cpp:860
CTxMemPoolEntry::GetLockPoints
const LockPoints & GetLockPoints() const
Definition: txmempool.h:149
CompareTxMemPoolEntryByDescendantScore
Definition: txmempool.h:264
SaltedUint256Hasher::hash
size_t hash(const uint256 &h) const
Definition: salteduint256hasher.h:19
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:56
indirectmap.h
CompareTxMemPoolEntryByAncestorFee::GetModFeeAndSize
void GetModFeeAndSize(const T &a, double &mod_fee, double &size) const
Definition: txmempool.h:353
CTxMemPoolEntry
Definition: txmempool.h:79
LOCK
#define LOCK(cs)
Definition: sync.h:241
MemPoolRemovalReason
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
Definition: txmempool.h:400
CTxMemPool::GetTransactionAncestry
void GetTransactionAncestry(const TxId &txid, size_t &ancestors, size_t &descendants) const
Calculate the ancestor and descendant count for the given transaction.
Definition: txmempool.cpp:1280
CTxMemPool::infoAll
std::vector< TxMempoolInfo > infoAll() const
Definition: txmempool.cpp:927
CTxMemPool::blockSinceLastRollingFeeBump
bool blockSinceLastRollingFeeBump
Definition: txmempool.h:509
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:1022
CTxMemPool::GetUnbroadcastTxs
std::set< TxId > GetUnbroadcastTxs() const
Returns transactions in unbroadcast set.
Definition: txmempool.h:817
CompareTxMemPoolEntryByAncestorFee::operator()
bool operator()(const T &a, const T &b) const
Definition: txmempool.h:335
LockPoints
Definition: txmempool.h:41
mempoolentry_txid
Definition: txmempool.h:248
CTxMemPool::trackPackageRemoved
void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1194
CTxMemPool::rollingMinimumFeeRate
double rollingMinimumFeeRate
minimum fee to get into the pool, decreases exponentially
Definition: txmempool.h:511
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:1100
CCoinsViewMemPool
CCoinsView that brings transactions from a mempool into view.
Definition: txmempool.h:950
CTxMemPool::size
unsigned long size() const
Definition: txmempool.h:781
DisconnectedBlockTransactions::cs
void pool cs
Definition: txmempool.h:1080
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:319
TxMempoolInfo
Information about a mempool transaction.
Definition: txmempool.h:379
CTxMemPoolEntry::UpdateLockPoints
void UpdateLockPoints(const LockPoints &lp)
Definition: txmempool.cpp:73
CTxMemPoolEntry::UpdateAncestorState
void UpdateAncestorState(int64_t modifySize, Amount modifyFee, int64_t modifyCount, int64_t modifySigOps)
Definition: txmempool.cpp:390
memusage::MallocUsage
static size_t MallocUsage(size_t alloc)
Compute the total memory used by allocating alloc bytes.
Definition: memusage.h:72
CompareTxMemPoolEntryByDescendantScore::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:266
salteduint256hasher.h
CTxMemPool::IsUnbroadcastTx
bool IsUnbroadcastTx(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns whether a txid is in the unbroadcast set.
Definition: txmempool.h:823
CTxMemPool::RemoveUnbroadcastTx
void RemoveUnbroadcastTx(const TxId &txid, const bool unchecked=false)
Removes a transaction from the unbroadcast set.
Definition: txmempool.cpp:1089
MEMPOOL_HEIGHT
static const uint32_t MEMPOOL_HEIGHT
Fake height value used in Coins to signify they are only in the memory pool(since 0....
Definition: txmempool.h:39
update_ancestor_state::modifyFee
Amount modifyFee
Definition: txmempool.h:224
update_ancestor_state::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:217
update_ancestor_state::modifySize
int64_t modifySize
Definition: txmempool.h:223
CTxMemPool::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.cpp:1077
CTxMemPoolEntry::GetTxSize
size_t GetTxSize() const
Definition: txmempool.h:141
CTxMemPoolEntry::GetSigOpCount
int64_t GetSigOpCount() const
Definition: txmempool.h:146
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:22
lp
LockPoints lp
Definition: mempool_eviction.cpp:16
DisconnectedBlockTransactions::DynamicMemoryUsage
size_t DynamicMemoryUsage() const
Definition: txmempool.h:1015
DisconnectedBlockTransactions
Definition: txmempool.h:981
DisconnectedBlockTransactions::addForBlock
void addForBlock(const std::vector< CTransactionRef > &vtx, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
Definition: txmempool.cpp:1304
CTxMemPoolEntry::GetMemPoolChildren
Children & GetMemPoolChildren() const
Definition: txmempool.h:184
MemPoolRemovalReason::BLOCK
@ BLOCK
Removed for block.
update_fee_delta::update_fee_delta
update_fee_delta(Amount _feeDelta)
Definition: txmempool.h:230
CTxMemPoolEntry::GetSigOpCountWithAncestors
int64_t GetSigOpCountWithAncestors() const
Definition: txmempool.h:177
SaltedTxIdHasher
Definition: txmempool.h:415
TxMempoolInfo::m_time
std::chrono::seconds m_time
Time the transaction entered the mempool.
Definition: txmempool.h:384
CTxMemPool::GetTotalTxSize
uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.h:786
CTxMemPoolEntry::GetSizeWithAncestors
uint64_t GetSizeWithAncestors() const
Definition: txmempool.h:174
CTxMemPool::GetFreshEpoch
EpochGuard GetFreshEpoch() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1448
CTxMemPoolEntry::GetCountWithDescendants
uint64_t GetCountWithDescendants() const
Definition: txmempool.h:163
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:23
CTxMemPool::cachedInnerUsage
uint64_t cachedInnerUsage
sum of dynamic memory usage of all the map elements (NOT the maps themselves)
Definition: txmempool.h:506
CTxMemPoolEntry::entryHeight
const unsigned int entryHeight
Chain height when entering the mempool.
Definition: txmempool.h:99
CTxMemPool::isSpent
bool isSpent(const COutPoint &outpoint) const
Definition: txmempool.cpp:415
amount.h
DisconnectedBlockTransactions::updateMempoolForReorg
void updateMempoolForReorg(const Config &config, bool fAddToMempool, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
Make mempool consistent after a reorg, by re-adding or recursively erasing disconnected block transac...
Definition: txmempool.cpp:1399
CTxMemPoolEntry::CTxMemPoolEntryRef
std::reference_wrapper< const CTxMemPoolEntry > CTxMemPoolEntryRef
Definition: txmempool.h:81
CTxMemPool::clear
void clear()
Definition: txmempool.cpp:700
CompareTxMemPoolEntryByEntryTime::operator()
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const
Definition: txmempool.h:323
CTxMemPool::_clear
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:688
CTxMemPoolEntry::nSigOpCountWithAncestors
int64_t nSigOpCountWithAncestors
Definition: txmempool.h:131
CTxMemPoolEntry::GetSizeWithDescendants
uint64_t GetSizeWithDescendants() const
Definition: txmempool.h:164
MemPoolRemovalReason::CONFLICT
@ CONFLICT
Removed for conflict with in-block transaction.
MemPoolRemovalReason::REORG
@ REORG
Removed for reorganization.
update_descendant_state::update_descendant_state
update_descendant_state(int64_t _modifySize, Amount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpCount)
Definition: txmempool.h:194
update_lock_points::update_lock_points
update_lock_points(const LockPoints &_lp)
Definition: txmempool.h:239
update_fee_delta::operator()
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:232
AssertLockHeld
AssertLockHeld(g_cs_orphans)
CTxMemPool::EpochGuard
EpochGuard: RAII-style guard for using epoch-based graph traversal algorithms.
Definition: txmempool.h:905
CTxMemPool::ClearPrioritisation
void ClearPrioritisation(const TxId &txid) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:1017
CTxMemPoolEntry::CTxMemPoolEntry
CTxMemPoolEntry(const CTransactionRef &_tx, const Amount _nFee, int64_t _nTime, unsigned int _entryHeight, bool spendsCoinbase, int64_t _nSigOpCount, LockPoints lp)
Definition: txmempool.cpp:28
CTxMemPool::LimitSize
void LimitSize(size_t limit, std::chrono::seconds age) EXCLUSIVE_LOCKS_REQUIRED(cs
Reduce the size of the mempool by expiring and then trimming the mempool.
Definition: txmempool.cpp:1128
update_descendant_state::modifySigOpCount
int64_t modifySigOpCount
Definition: txmempool.h:208
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:652
CTxMemPool::removeRecursive
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Definition: txmempool.cpp:546
cs_main
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:103
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:521
CTxMemPoolEntry::GetVirtualSizeWithDescendants
uint64_t GetVirtualSizeWithDescendants() const
Definition: txmempool.cpp:53
CTxMemPoolEntry::GetTx
const CTransaction & GetTx() const
Definition: txmempool.h:138