Dash Core  0.12.2.1
P2P Digital Currency
txmempool.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 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 <list>
10 #include <set>
11 
12 #include "addressindex.h"
13 #include "spentindex.h"
14 #include "amount.h"
15 #include "coins.h"
16 #include "primitives/transaction.h"
17 #include "sync.h"
18 
19 #undef foreach
20 #include "boost/multi_index_container.hpp"
21 #include "boost/multi_index/ordered_index.hpp"
22 
23 class CAutoFile;
24 class CBlockIndex;
25 
26 inline double AllowFreeThreshold()
27 {
28  return COIN * 144 / 250;
29 }
30 
31 inline bool AllowFree(double dPriority)
32 {
33  // Large (in bytes) low-priority (new, small-coin) transactions
34  // need a fee.
35  return dPriority > AllowFreeThreshold();
36 }
37 
38 
40 static const unsigned int MEMPOOL_HEIGHT = 0x7FFFFFFF;
41 
42 struct LockPoints
43 {
44  // Will be set to the blockchain height and median time past
45  // values that would be necessary to satisfy all relative locktime
46  // constraints (BIP68) of this tx given our view of block chain history
47  int height;
48  int64_t time;
49  // As long as the current chain descends from the highest height block
50  // containing one of the inputs used in the calculation, then the cached
51  // values are still valid even after a reorg.
53 
54  LockPoints() : height(0), time(0), maxInputBlock(NULL) { }
55 };
56 
57 class CTxMemPool;
58 
77 {
78 private:
81  size_t nTxSize;
82  size_t nModSize;
83  size_t nUsageSize;
84  int64_t nTime;
85  double entryPriority;
86  unsigned int entryHeight;
90  unsigned int sigOpCount;
91  int64_t feeDelta;
93 
94  // Information about descendants of this transaction that are in the
95  // mempool; if we remove this transaction we must remove all of these
96  // descendants as well. if nCountWithDescendants is 0, treat this entry as
97  // dirty, and nSizeWithDescendants and nModFeesWithDescendants will not be
98  // correct.
102 
103 public:
104  CTxMemPoolEntry(const CTransaction& _tx, const CAmount& _nFee,
105  int64_t _nTime, double _entryPriority, unsigned int _entryHeight,
106  bool poolHasNoInputsOf, CAmount _inChainInputValue, bool spendsCoinbase,
107  unsigned int nSigOps, LockPoints lp);
108  CTxMemPoolEntry(const CTxMemPoolEntry& other);
109 
110  const CTransaction& GetTx() const { return this->tx; }
115  double GetPriority(unsigned int currentHeight) const;
116  const CAmount& GetFee() const { return nFee; }
117  size_t GetTxSize() const { return nTxSize; }
118  int64_t GetTime() const { return nTime; }
119  unsigned int GetHeight() const { return entryHeight; }
120  bool WasClearAtEntry() const { return hadNoDependencies; }
121  unsigned int GetSigOpCount() const { return sigOpCount; }
122  int64_t GetModifiedFee() const { return nFee + feeDelta; }
123  size_t DynamicMemoryUsage() const { return nUsageSize; }
124  const LockPoints& GetLockPoints() const { return lockPoints; }
125 
126  // Adjusts the descendant state, if this entry is not dirty.
127  void UpdateState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount);
128  // Updates the fee delta used for mining priority score, and the
129  // modified fees with descendants.
130  void UpdateFeeDelta(int64_t feeDelta);
131  // Update the LockPoints after a reorg
132  void UpdateLockPoints(const LockPoints& lp);
133 
138  void SetDirty();
139  bool IsDirty() const { return nCountWithDescendants == 0; }
140 
141  uint64_t GetCountWithDescendants() const { return nCountWithDescendants; }
142  uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
144 
145  bool GetSpendsCoinbase() const { return spendsCoinbase; }
146 };
147 
148 // Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index.
150 {
151  update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) :
152  modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount)
153  {}
154 
157 
158  private:
159  int64_t modifySize;
161  int64_t modifyCount;
162 };
163 
164 struct set_dirty
165 {
167  { e.SetDirty(); }
168 };
169 
171 {
172  update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
173 
175 
176 private:
177  int64_t feeDelta;
178 };
179 
181 {
182  update_lock_points(const LockPoints& _lp) : lp(_lp) { }
183 
185 
186 private:
187  const LockPoints& lp;
188 };
189 
190 // extracts a TxMemPoolEntry's transaction hash
192 {
195  {
196  return entry.GetTx().GetHash();
197  }
198 };
199 
205 {
206 public:
207  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b)
208  {
209  bool fUseADescendants = UseDescendantScore(a);
210  bool fUseBDescendants = UseDescendantScore(b);
211 
212  double aModFee = fUseADescendants ? a.GetModFeesWithDescendants() : a.GetModifiedFee();
213  double aSize = fUseADescendants ? a.GetSizeWithDescendants() : a.GetTxSize();
214 
215  double bModFee = fUseBDescendants ? b.GetModFeesWithDescendants() : b.GetModifiedFee();
216  double bSize = fUseBDescendants ? b.GetSizeWithDescendants() : b.GetTxSize();
217 
218  // Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
219  double f1 = aModFee * bSize;
220  double f2 = aSize * bModFee;
221 
222  if (f1 == f2) {
223  return a.GetTime() >= b.GetTime();
224  }
225  return f1 < f2;
226  }
227 
228  // Calculate which score to use for an entry (avoiding division).
230  {
231  double f1 = (double)a.GetModifiedFee() * a.GetSizeWithDescendants();
232  double f2 = (double)a.GetModFeesWithDescendants() * a.GetTxSize();
233  return f2 > f1;
234  }
235 };
236 
242 {
243 public:
244  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b)
245  {
246  double f1 = (double)a.GetModifiedFee() * b.GetTxSize();
247  double f2 = (double)b.GetModifiedFee() * a.GetTxSize();
248  if (f1 == f2) {
249  return b.GetTx().GetHash() < a.GetTx().GetHash();
250  }
251  return f1 > f2;
252  }
253 };
254 
256 {
257 public:
258  bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b)
259  {
260  return a.GetTime() < b.GetTime();
261  }
262 };
263 
265 
267 class CInPoint
268 {
269 public:
271  uint32_t n;
272 
273  CInPoint() { SetNull(); }
274  CInPoint(const CTransaction* ptxIn, uint32_t nIn) { ptx = ptxIn; n = nIn; }
275  void SetNull() { ptx = NULL; n = (uint32_t) -1; }
276  bool IsNull() const { return (ptx == NULL && n == (uint32_t) -1); }
277  size_t DynamicMemoryUsage() const { return 0; }
278 };
279 
358 {
359 private:
360  uint32_t nCheckFrequency;
361  unsigned int nTransactionsUpdated;
363 
364  uint64_t totalTxSize;
365  uint64_t cachedInnerUsage;
366 
368 
369  mutable int64_t lastRollingFeeUpdate;
371  mutable double rollingMinimumFeeRate;
372 
373  void trackPackageRemoved(const CFeeRate& rate);
374 
375 public:
376 
377  static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12; // public only for testing
378 
379  typedef boost::multi_index_container<
381  boost::multi_index::indexed_by<
382  // sorted by txid
383  boost::multi_index::ordered_unique<mempoolentry_txid>,
384  // sorted by fee rate
385  boost::multi_index::ordered_non_unique<
386  boost::multi_index::identity<CTxMemPoolEntry>,
388  >,
389  // sorted by entry time
390  boost::multi_index::ordered_non_unique<
391  boost::multi_index::identity<CTxMemPoolEntry>,
393  >,
394  // sorted by score (for mining prioritization)
395  boost::multi_index::ordered_unique<
396  boost::multi_index::identity<CTxMemPoolEntry>,
398  >
399  >
401 
404  typedef indexed_transaction_set::nth_index<0>::type::iterator txiter;
406  bool operator()(const txiter &a, const txiter &b) const {
407  return a->GetTx().GetHash() < b->GetTx().GetHash();
408  }
409  };
410  typedef std::set<txiter, CompareIteratorByHash> setEntries;
411 
412  const setEntries & GetMemPoolParents(txiter entry) const;
413  const setEntries & GetMemPoolChildren(txiter entry) const;
414 private:
415  typedef std::map<txiter, setEntries, CompareIteratorByHash> cacheMap;
416 
417  struct TxLinks {
420  };
421 
422  typedef std::map<txiter, TxLinks, CompareIteratorByHash> txlinksMap;
424 
425  typedef std::map<CMempoolAddressDeltaKey, CMempoolAddressDelta, CMempoolAddressDeltaKeyCompare> addressDeltaMap;
427 
428  typedef std::map<uint256, std::vector<CMempoolAddressDeltaKey> > addressDeltaMapInserted;
430 
431  typedef std::map<CSpentIndexKey, CSpentIndexValue, CSpentIndexKeyCompare> mapSpentIndex;
433 
434  typedef std::map<uint256, std::vector<CSpentIndexKey> > mapSpentIndexInserted;
436 
437  void UpdateParent(txiter entry, txiter parent, bool add);
438  void UpdateChild(txiter entry, txiter child, bool add);
439 
440 public:
441  std::map<COutPoint, CInPoint> mapNextTx;
442  std::map<uint256, std::pair<double, CAmount> > mapDeltas;
443 
449  CTxMemPool(const CFeeRate& _minReasonableRelayFee);
450  ~CTxMemPool();
451 
458  void check(const CCoinsViewCache *pcoins) const;
459  void setSanityCheck(double dFrequency = 1.0) { nCheckFrequency = dFrequency * 4294967295.0; }
460 
461  // addUnchecked must updated state for all ancestors of a given transaction,
462  // to track size/count of descendant transactions. First version of
463  // addUnchecked can be used to have it call CalculateMemPoolAncestors(), and
464  // then invoke the second version.
465  bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, bool fCurrentEstimate = true);
466  bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool fCurrentEstimate = true);
467 
468  void addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view);
469  bool getAddressIndex(std::vector<std::pair<uint160, int> > &addresses,
470  std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> > &results);
471  bool removeAddressIndex(const uint256 txhash);
472 
473  void addSpentIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view);
475  bool removeSpentIndex(const uint256 txhash);
476 
477  void remove(const CTransaction &tx, std::list<CTransaction>& removed, bool fRecursive = false);
478  void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
479  void removeConflicts(const CTransaction &tx, std::list<CTransaction>& removed);
480  void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
481  std::list<CTransaction>& conflicts, bool fCurrentEstimate = true);
482  void clear();
483  void _clear(); //lock free
484  void queryHashes(std::vector<uint256>& vtxid);
485  void pruneSpent(const uint256& hash, CCoins &coins);
486  unsigned int GetTransactionsUpdated() const;
487  void AddTransactionsUpdated(unsigned int n);
492  bool HasNoInputsOf(const CTransaction& tx) const;
493 
495  void PrioritiseTransaction(const uint256 hash, const std::string strHash, double dPriorityDelta, const CAmount& nFeeDelta);
496  void ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta) const;
497  void ClearPrioritisation(const uint256 hash);
498 
499 public:
503  void RemoveStaged(setEntries &stage);
504 
514  void UpdateTransactionsFromBlock(const std::vector<uint256> &hashesToUpdate);
515 
526  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);
527 
531  void CalculateDescendants(txiter it, setEntries &setDescendants);
532 
539  CFeeRate GetMinFee(size_t sizelimit) const;
540  void UpdateMinFee(const CFeeRate& _minReasonableRelayFee);
541 
546  void TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRemaining=NULL);
547 
549  int Expire(int64_t time);
550 
551  unsigned long size()
552  {
553  LOCK(cs);
554  return mapTx.size();
555  }
556 
557  uint64_t GetTotalTxSize()
558  {
559  LOCK(cs);
560  return totalTxSize;
561  }
562 
563  bool exists(uint256 hash) const
564  {
565  LOCK(cs);
566  return (mapTx.count(hash) != 0);
567  }
568 
569  bool lookup(uint256 hash, CTransaction& result) const;
570 
575  CFeeRate estimateSmartFee(int nBlocks, int *answerFoundAtBlocks = NULL) const;
576 
578  CFeeRate estimateFee(int nBlocks) const;
579 
584  double estimateSmartPriority(int nBlocks, int *answerFoundAtBlocks = NULL) const;
585 
587  double estimatePriority(int nBlocks) const;
588 
590  bool WriteFeeEstimates(CAutoFile& fileout) const;
591  bool ReadFeeEstimates(CAutoFile& filein);
592 
593  size_t DynamicMemoryUsage() const;
594 
595 private:
612  bool UpdateForDescendants(txiter updateIt,
613  int maxDescendantsToVisit,
614  cacheMap &cachedDescendants,
615  const std::set<uint256> &setExclude);
617  void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors);
619  void UpdateForRemoveFromMempool(const setEntries &entriesToRemove);
621  void UpdateChildrenForRemoval(txiter entry);
622 
631  void removeUnchecked(txiter entry);
632 };
633 
639 {
640 protected:
642 
643 public:
644  CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn);
645  bool GetCoins(const uint256 &txid, CCoins &coins) const;
646  bool HaveCoins(const uint256 &txid) const;
647 };
648 
649 // We want to sort transactions by coin age priority
650 typedef std::pair<double, CTxMemPool::txiter> TxCoinAgePriority;
651 
653 {
655  {
656  if (a.first == b.first)
657  return CompareTxMemPoolEntryByScore()(*(b.second), *(a.second)); //Reverse order to make sort less than
658  return a.first < b.first;
659  }
660 };
661 
662 #endif // BITCOIN_TXMEMPOOL_H
bool UseDescendantScore(const CTxMemPoolEntry &a)
Definition: txmempool.h:229
int64_t lastRollingFeeUpdate
Definition: txmempool.h:369
void TrimToSize(size_t sizelimit, std::vector< uint256 > *pvNoSpendsRemaining=NULL)
Definition: txmempool.cpp:1116
void removeConflicts(const CTransaction &tx, std::list< CTransaction > &removed)
Definition: txmempool.cpp:685
void UpdateForRemoveFromMempool(const setEntries &entriesToRemove)
Definition: txmempool.cpp:268
std::map< CMempoolAddressDeltaKey, CMempoolAddressDelta, CMempoolAddressDeltaKeyCompare > addressDeltaMap
Definition: txmempool.h:425
update_fee_delta(int64_t _feeDelta)
Definition: txmempool.h:172
void UpdateFeeDelta(int64_t feeDelta)
Definition: txmempool.cpp:59
unsigned int entryHeight
Priority when entering the mempool.
Definition: txmempool.h:86
int Expire(int64_t time)
Definition: txmempool.cpp:1014
unsigned long size()
Definition: txmempool.h:551
Definition: coins.h:73
int height
Definition: txmempool.h:47
void setSanityCheck(double dFrequency=1.0)
Definition: txmempool.h:459
std::map< uint256, std::vector< CMempoolAddressDeltaKey > > addressDeltaMapInserted
Definition: txmempool.h:428
bool GetSpendsCoinbase() const
Definition: txmempool.h:145
addressDeltaMapInserted mapAddressInserted
Definition: txmempool.h:429
size_t nUsageSize
... and modified size for priority
Definition: txmempool.h:83
void queryHashes(std::vector< uint256 > &vtxid)
Definition: txmempool.cpp:859
bool IsDirty() const
Definition: txmempool.h:139
unsigned int GetHeight() const
Definition: txmempool.h:119
void SetNull()
Definition: txmempool.h:275
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b)
Definition: txmempool.h:207
size_t GetTxSize() const
Definition: txmempool.h:117
bool ReadFeeEstimates(CAutoFile &filein)
Definition: txmempool.cpp:916
CFeeRate estimateSmartFee(int nBlocks, int *answerFoundAtBlocks=NULL) const
Definition: txmempool.cpp:883
double AllowFreeThreshold()
Definition: txmempool.h:26
static const CAmount COIN
Definition: amount.h:16
uint64_t totalTxSize
Definition: txmempool.h:364
static FILE * fileout
Definition: util.cpp:210
std::map< txiter, setEntries, CompareIteratorByHash > cacheMap
Definition: txmempool.h:415
unsigned int nTransactionsUpdated
Value n means that n times in 2^32 we check.
Definition: txmempool.h:361
CInPoint(const CTransaction *ptxIn, uint32_t nIn)
Definition: txmempool.h:274
bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
Definition: txmempool.cpp:984
bool removeAddressIndex(const uint256 txhash)
Definition: txmempool.cpp:484
double estimateSmartPriority(int nBlocks, int *answerFoundAtBlocks=NULL) const
Definition: txmempool.cpp:893
CAmount nModFeesWithDescendants
... and size
Definition: txmempool.h:101
int64_t feeDelta
Legacy sig ops plus P2SH sig op count.
Definition: txmempool.h:91
double entryPriority
Local time when entering the mempool.
Definition: txmempool.h:85
int64_t feeDelta
Definition: txmempool.h:177
std::map< COutPoint, CInPoint > mapNextTx
Definition: txmempool.h:441
void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors)
Definition: txmempool.cpp:245
LockPoints()
Definition: txmempool.h:54
int flags
Definition: dash-tx.cpp:326
CFeeRate minReasonableRelayFee
sum of dynamic memory usage of all the map elements (NOT the maps themselves)
Definition: txmempool.h:367
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:155
uint64_t GetCountWithDescendants() const
Definition: txmempool.h:141
void UpdateParent(txiter entry, txiter parent, bool add)
Definition: txmempool.cpp:1050
void AddTransactionsUpdated(unsigned int n)
Definition: txmempool.cpp:366
indexed_transaction_set mapTx
Definition: txmempool.h:403
std::pair< double, CTxMemPool::txiter > TxCoinAgePriority
Definition: txmempool.h:650
void UpdateTransactionsFromBlock(const std::vector< uint256 > &hashesToUpdate)
Definition: txmempool.cpp:137
uint32_t nCheckFrequency
Definition: txmempool.h:360
CTxMemPool(const CFeeRate &_minReasonableRelayFee)
Definition: txmempool.cpp:328
uint64_t GetTotalTxSize()
Definition: txmempool.h:557
size_t DynamicMemoryUsage() const
Definition: txmempool.h:277
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)
Definition: txmempool.cpp:183
unsigned int sigOpCount
keep track of transactions that spend a coinbase
Definition: txmempool.h:90
mapSpentIndex mapSpent
Definition: txmempool.h:432
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:184
std::map< CSpentIndexKey, CSpentIndexValue, CSpentIndexKeyCompare > mapSpentIndex
Definition: txmempool.h:431
update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount)
Definition: txmempool.h:151
const CAmount & GetFee() const
Definition: txmempool.h:116
bool removeSpentIndex(const uint256 txhash)
Definition: txmempool.cpp:549
void UpdateLockPoints(const LockPoints &lp)
Definition: txmempool.cpp:65
bool lookup(uint256 hash, CTransaction &result) const
Definition: txmempool.cpp:869
CInPoint()
Definition: txmempool.h:273
void ClearPrioritisation(const uint256 hash)
Definition: txmempool.cpp:968
mapSpentIndexInserted mapSpentInserted
Definition: txmempool.h:435
void ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta) const
Definition: txmempool.cpp:957
int64_t CAmount
Definition: amount.h:14
bool getSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value)
Definition: txmempool.cpp:536
bool exists(uint256 hash) const
Definition: txmempool.h:563
LockPoints lockPoints
Used for determining the priority of the transaction for mining in a block.
Definition: txmempool.h:92
std::map< txiter, TxLinks, CompareIteratorByHash > txlinksMap
Definition: txmempool.h:422
bool HasNoInputsOf(const CTransaction &tx) const
Definition: txmempool.cpp:974
result_type operator()(const CTxMemPoolEntry &entry) const
Definition: txmempool.h:194
CCriticalSection cs
Definition: txmempool.h:402
indexed_transaction_set::nth_index< 0 >::type::iterator txiter
Definition: txmempool.h:404
bool blockSinceLastRollingFeeBump
Definition: txmempool.h:370
uint64_t nSizeWithDescendants
number of descendant transactions
Definition: txmempool.h:100
void CalculateDescendants(txiter it, setEntries &setDescendants)
Definition: txmempool.cpp:588
const setEntries & GetMemPoolParents(txiter entry) const
Definition: txmempool.cpp:1060
bool operator()(const txiter &a, const txiter &b) const
Definition: txmempool.h:406
int64_t nTime
... and total memory usage
Definition: txmempool.h:84
void UpdateMinFee(const CFeeRate &_minReasonableRelayFee)
Definition: txmempool.cpp:1100
void removeForBlock(const std::vector< CTransaction > &vtx, unsigned int nBlockHeight, std::list< CTransaction > &conflicts, bool fCurrentEstimate=true)
Definition: txmempool.cpp:706
#define LOCK(cs)
Definition: sync.h:168
const CTransaction & GetTx() const
Definition: txmempool.h:110
bool IsNull() const
Definition: txmempool.h:276
size_t DynamicMemoryUsage() const
Definition: txmempool.cpp:1000
uint64_t cachedInnerUsage
sum of all mempool tx&#39; byte sizes
Definition: txmempool.h:365
addressDeltaMap mapAddress
Definition: txmempool.h:426
void clear()
Definition: txmempool.cpp:745
CTxMemPoolEntry(const CTransaction &_tx, const CAmount &_nFee, int64_t _nTime, double _entryPriority, unsigned int _entryHeight, bool poolHasNoInputsOf, CAmount _inChainInputValue, bool spendsCoinbase, unsigned int nSigOps, LockPoints lp)
... and total fees (all including us)
Definition: txmempool.cpp:23
void UpdateChildrenForRemoval(txiter entry)
Definition: txmempool.cpp:260
static const int ROLLING_FEE_HALFLIFE
Definition: txmempool.h:377
void check(const CCoinsViewCache *pcoins) const
Definition: txmempool.cpp:751
CBlockIndex * maxInputBlock
Definition: txmempool.h:52
size_t nTxSize
Cached to avoid expensive parent-transaction lookups.
Definition: txmempool.h:81
bool AllowFree(double dPriority)
Definition: txmempool.h:31
size_t nModSize
... and avoid recomputing tx size
Definition: txmempool.h:82
void removeUnchecked(txiter entry)
Definition: txmempool.cpp:565
uint256 result_type
Definition: txmempool.h:193
void addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view)
Definition: txmempool.cpp:426
CAmount inChainInputValue
Not dependent on any other txs when it entered the mempool.
Definition: txmempool.h:88
int64_t time
Definition: txmempool.h:48
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:410
void trackPackageRemoved(const CFeeRate &rate)
minimum fee to get into the pool, decreases exponentially
Definition: txmempool.cpp:1108
bool operator()(const TxCoinAgePriority &a, const TxCoinAgePriority &b)
Definition: txmempool.h:654
int64_t GetTime() const
Definition: txmempool.h:118
txlinksMap mapLinks
Definition: txmempool.h:423
size_t DynamicMemoryUsage() const
Definition: txmempool.h:123
std::map< uint256, std::pair< double, CAmount > > mapDeltas
Definition: txmempool.h:442
CAmount GetModFeesWithDescendants() const
Definition: txmempool.h:143
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b)
Definition: txmempool.h:244
unsigned int GetSigOpCount() const
Definition: txmempool.h:121
bool getAddressIndex(std::vector< std::pair< uint160, int > > &addresses, std::vector< std::pair< CMempoolAddressDeltaKey, CMempoolAddressDelta > > &results)
Definition: txmempool.cpp:470
const CTransaction * ptx
Definition: txmempool.h:270
int64_t GetModifiedFee() const
Definition: txmempool.h:122
const setEntries & GetMemPoolChildren(txiter entry) const
Definition: txmempool.cpp:1068
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b)
Definition: txmempool.h:258
bool HaveCoins(const uint256 &txid) const
Definition: txmempool.cpp:996
uint64_t nCountWithDescendants
Track the height and time at which tx was final.
Definition: txmempool.h:99
const LockPoints & lp
Definition: txmempool.h:187
const uint256 & GetHash() const
Definition: transaction.h:262
void UpdateChild(txiter entry, txiter child, bool add)
Definition: txmempool.cpp:1040
CAmount nFee
Definition: txmempool.h:80
double rollingMinimumFeeRate
Definition: txmempool.h:371
void addSpentIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view)
Definition: txmempool.cpp:500
bool WriteFeeEstimates(CAutoFile &fileout) const
Definition: txmempool.cpp:900
void pruneSpent(const uint256 &hash, CCoins &coins)
Definition: txmempool.cpp:347
CFeeRate GetMinFee(size_t sizelimit) const
Definition: txmempool.cpp:1076
void _clear()
Definition: txmempool.cpp:732
bool hadNoDependencies
Chain height when entering the mempool.
Definition: txmempool.h:87
CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn)
Definition: txmempool.cpp:982
update_lock_points(const LockPoints &_lp)
Definition: txmempool.h:182
CTransaction tx
Definition: txmempool.h:79
double GetPriority(unsigned int currentHeight) const
Definition: txmempool.cpp:50
void PrioritiseTransaction(const uint256 hash, const std::string strHash, double dPriorityDelta, const CAmount &nFeeDelta)
Definition: txmempool.cpp:934
std::map< uint256, std::vector< CSpentIndexKey > > mapSpentIndexInserted
Definition: txmempool.h:434
bool WasClearAtEntry() const
Definition: txmempool.h:120
static const unsigned int MEMPOOL_HEIGHT
Definition: txmempool.h:40
boost::multi_index_container< CTxMemPoolEntry, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< mempoolentry_txid >, boost::multi_index::ordered_non_unique< boost::multi_index::identity< CTxMemPoolEntry >, CompareTxMemPoolEntryByDescendantScore >, boost::multi_index::ordered_non_unique< boost::multi_index::identity< CTxMemPoolEntry >, CompareTxMemPoolEntryByEntryTime >, boost::multi_index::ordered_unique< boost::multi_index::identity< CTxMemPoolEntry >, CompareTxMemPoolEntryByScore > > > indexed_transaction_set
Definition: txmempool.h:400
CFeeRate estimateFee(int nBlocks) const
Definition: txmempool.cpp:878
uint32_t n
Definition: txmempool.h:271
CBlockPolicyEstimator * minerPolicyEstimator
Definition: txmempool.h:362
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags)
Definition: txmempool.cpp:649
CTxMemPool & mempool
Definition: txmempool.h:641
void RemoveStaged(setEntries &stage)
Definition: txmempool.cpp:1006
bool spendsCoinbase
Sum of all txin values that are already in blockchain.
Definition: txmempool.h:89
bool UpdateForDescendants(txiter updateIt, int maxDescendantsToVisit, cacheMap &cachedDescendants, const std::set< uint256 > &setExclude)
Definition: txmempool.cpp:73
void UpdateState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount)
Definition: txmempool.cpp:317
uint64_t GetSizeWithDescendants() const
Definition: txmempool.h:142
double estimatePriority(int nBlocks) const
Definition: txmempool.cpp:888
bool addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry, bool fCurrentEstimate=true)
Definition: txmempool.cpp:1030
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:166
unsigned int GetTransactionsUpdated() const
Definition: txmempool.cpp:360
void operator()(CTxMemPoolEntry &e)
Definition: txmempool.h:174
result
Definition: rpcuser.py:37
const LockPoints & GetLockPoints() const
Definition: txmempool.h:124