22 int64_t _nTime,
unsigned int _entryHeight,
23 bool _spendsCoinbase, int64_t _sigOpsCost,
LockPoints lp)
24 : tx(_tx), nFee(_nFee), nTxWeight(GetTransactionWeight(*tx)), nUsageSize(RecursiveDynamicUsage(tx)), nTime(_nTime), entryHeight(_entryHeight),
25 spendsCoinbase(_spendsCoinbase), sigOpCost(_sigOpsCost), lockPoints(lp)
64 while (!stageEntries.empty()) {
65 const txiter cit = *stageEntries.begin();
66 setAllDescendants.insert(cit);
67 stageEntries.erase(cit);
69 for (
txiter childEntry : setChildren) {
70 cacheMap::iterator cacheIt = cachedDescendants.find(childEntry);
71 if (cacheIt != cachedDescendants.end()) {
74 for (
txiter cacheEntry : cacheIt->second) {
75 setAllDescendants.insert(cacheEntry);
77 }
else if (!setAllDescendants.count(childEntry)) {
79 stageEntries.insert(childEntry);
85 int64_t modifySize = 0;
87 int64_t modifyCount = 0;
88 for (
txiter cit : setAllDescendants) {
89 if (!setExclude.count(cit->GetTx().GetHash())) {
90 modifySize += cit->GetTxSize();
91 modifyFee += cit->GetModifiedFee();
93 cachedDescendants[updateIt].insert(cit);
95 mapTx.modify(cit,
update_ancestor_state(updateIt->GetTxSize(), updateIt->GetModifiedFee(), 1, updateIt->GetSigOpCost()));
112 cacheMap mapMemPoolDescendantsToUpdate;
116 std::set<uint256> setAlreadyIncluded(vHashesToUpdate.begin(), vHashesToUpdate.end());
127 txiter it = mapTx.find(hash);
128 if (it == mapTx.end()) {
131 auto iter = mapNextTx.lower_bound(
COutPoint(hash, 0));
134 for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) {
135 const uint256 &childHash = iter->second->GetHash();
136 txiter childIter = mapTx.find(childHash);
137 assert(childIter != mapTx.end());
140 if (setChildren.insert(childIter).second && !setAlreadyIncluded.count(childHash)) {
154 if (fSearchForParents) {
158 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
159 boost::optional<txiter> piter =
GetIter(tx.
vin[i].prevout.hash);
161 parentHashes.insert(*piter);
162 if (parentHashes.size() + 1 > limitAncestorCount) {
163 errString =
strprintf(
"too many unconfirmed parents [limit: %u]", limitAncestorCount);
171 txiter it = mapTx.iterator_to(entry);
175 size_t totalSizeWithAncestors = entry.
GetTxSize();
177 while (!parentHashes.empty()) {
178 txiter stageit = *parentHashes.begin();
180 setAncestors.insert(stageit);
181 parentHashes.erase(stageit);
182 totalSizeWithAncestors += stageit->GetTxSize();
184 if (stageit->GetSizeWithDescendants() + entry.
GetTxSize() > limitDescendantSize) {
185 errString =
strprintf(
"exceeds descendant size limit for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limitDescendantSize);
187 }
else if (stageit->GetCountWithDescendants() + 1 > limitDescendantCount) {
188 errString =
strprintf(
"too many descendants for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limitDescendantCount);
190 }
else if (totalSizeWithAncestors > limitAncestorSize) {
191 errString =
strprintf(
"exceeds ancestor size limit [limit: %u]", limitAncestorSize);
196 for (
txiter phash : setMemPoolParents) {
198 if (setAncestors.count(phash) == 0) {
199 parentHashes.insert(phash);
201 if (parentHashes.size() + setAncestors.size() + 1 > limitAncestorCount) {
202 errString =
strprintf(
"too many unconfirmed ancestors [limit: %u]", limitAncestorCount);
215 for (
txiter piter : parentIters) {
218 const int64_t updateCount = (add ? 1 : -1);
219 const int64_t updateSize = updateCount * it->GetTxSize();
220 const CAmount updateFee = updateCount * it->GetModifiedFee();
221 for (
txiter ancestorIt : setAncestors) {
228 int64_t updateCount = setAncestors.size();
229 int64_t updateSize = 0;
231 int64_t updateSigOpsCost = 0;
232 for (
txiter ancestorIt : setAncestors) {
233 updateSize += ancestorIt->GetTxSize();
234 updateFee += ancestorIt->GetModifiedFee();
235 updateSigOpsCost += ancestorIt->GetSigOpCost();
243 for (
txiter updateIt : setMemPoolChildren) {
252 const uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
253 if (updateDescendants) {
260 for (
txiter removeIt : entriesToRemove) {
263 setDescendants.erase(removeIt);
264 int64_t modifySize = -((int64_t)removeIt->GetTxSize());
265 CAmount modifyFee = -removeIt->GetModifiedFee();
266 int modifySigOps = -removeIt->GetSigOpCost();
267 for (
txiter dit : setDescendants) {
272 for (
txiter removeIt : entriesToRemove) {
301 for (
txiter removeIt : entriesToRemove) {
327 nTransactionsUpdated(0), minerPolicyEstimator(estimator)
340 return mapNextTx.count(outpoint);
361 indexed_transaction_set::iterator newit = mapTx.insert(entry).first;
379 std::set<uint256> setParentTransactions;
380 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
381 mapNextTx.insert(std::make_pair(&tx.
vin[i].prevout, &tx));
382 setParentTransactions.insert(tx.
vin[i].prevout.hash);
392 for (
const auto& pit :
GetIterSet(setParentTransactions)) {
403 newit->vTxHashesIdx =
vTxHashes.size() - 1;
409 const uint256 hash = it->GetTx().GetHash();
410 for (
const CTxIn& txin : it->GetTx().vin)
411 mapNextTx.erase(txin.prevout);
415 vTxHashes[it->vTxHashesIdx].second->vTxHashesIdx = it->vTxHashesIdx;
440 if (setDescendants.count(entryit) == 0) {
441 stage.insert(entryit);
446 while (!stage.empty()) {
447 txiter it = *stage.begin();
448 setDescendants.insert(it);
452 for (
txiter childiter : setChildren) {
453 if (!setDescendants.count(childiter)) {
454 stage.insert(childiter);
467 if (origit != mapTx.end()) {
468 txToRemove.insert(origit);
474 for (
unsigned int i = 0; i < origTx.
vout.size(); i++) {
476 if (it == mapNextTx.end())
478 txiter nextit = mapTx.find(it->second->GetHash());
479 assert(nextit != mapTx.end());
480 txToRemove.insert(nextit);
484 for (
txiter it : txToRemove) {
497 for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
504 txToRemove.insert(it);
505 }
else if (it->GetSpendsCoinbase()) {
507 indexed_transaction_set::const_iterator it2 = mapTx.find(txin.
prevout.
hash);
508 if (it2 != mapTx.end())
511 if (nCheckFrequency != 0) assert(!coin.
IsSpent());
513 txToRemove.insert(it);
523 for (
txiter it : txToRemove) {
534 auto it = mapNextTx.find(txin.
prevout);
535 if (it != mapNextTx.end()) {
537 if (txConflict != tx)
552 std::vector<const CTxMemPoolEntry*> entries;
553 for (
const auto& tx : vtx)
557 indexed_transaction_set::iterator i = mapTx.find(hash);
558 if (i != mapTx.end())
559 entries.push_back(&*i);
563 for (
const auto& tx : vtx)
565 txiter it = mapTx.find(tx->GetHash());
566 if (it != mapTx.end()) {
602 assert(fCheckResult);
609 if (nCheckFrequency == 0)
612 if (
GetRand(std::numeric_limits<uint32_t>::max()) >= nCheckFrequency)
615 LogPrint(
BCLog::MEMPOOL,
"Checking mempool with %u transactions and %u inputs\n", (
unsigned int)mapTx.size(), (
unsigned int)mapNextTx.size());
617 uint64_t checkTotal = 0;
618 uint64_t innerUsage = 0;
620 CCoinsViewCache mempoolDuplicate(const_cast<CCoinsViewCache*>(pcoins));
623 std::list<const CTxMemPoolEntry*> waitingOnDependants;
624 for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
626 checkTotal += it->GetTxSize();
627 innerUsage += it->DynamicMemoryUsage();
629 txlinksMap::const_iterator linksiter =
mapLinks.find(it);
630 assert(linksiter !=
mapLinks.end());
631 const TxLinks &links = linksiter->second;
632 innerUsage += memusage::DynamicUsage(links.parents) + memusage::DynamicUsage(links.children);
633 bool fDependsWait =
false;
637 indexed_transaction_set::const_iterator it2 = mapTx.find(txin.
prevout.
hash);
638 if (it2 != mapTx.end()) {
642 setParentCheck.insert(it2);
647 auto it3 = mapNextTx.find(txin.
prevout);
648 assert(it3 != mapNextTx.end());
649 assert(it3->first == &txin.
prevout);
650 assert(it3->second == &tx);
656 uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
659 uint64_t nCountCheck = setAncestors.size() + 1;
660 uint64_t nSizeCheck = it->GetTxSize();
661 CAmount nFeesCheck = it->GetModifiedFee();
662 int64_t nSigOpCheck = it->GetSigOpCost();
664 for (
txiter ancestorIt : setAncestors) {
665 nSizeCheck += ancestorIt->GetTxSize();
666 nFeesCheck += ancestorIt->GetModifiedFee();
667 nSigOpCheck += ancestorIt->GetSigOpCost();
670 assert(it->GetCountWithAncestors() == nCountCheck);
671 assert(it->GetSizeWithAncestors() == nSizeCheck);
672 assert(it->GetSigOpCostWithAncestors() == nSigOpCheck);
673 assert(it->GetModFeesWithAncestors() == nFeesCheck);
677 auto iter = mapNextTx.lower_bound(
COutPoint(it->GetTx().GetHash(), 0));
678 uint64_t child_sizes = 0;
679 for (; iter != mapNextTx.end() && iter->first->hash == it->GetTx().GetHash(); ++iter) {
680 txiter childit = mapTx.find(iter->second->GetHash());
681 assert(childit != mapTx.end());
682 if (setChildrenCheck.insert(childit).second) {
683 child_sizes += childit->GetTxSize();
689 assert(it->GetSizeWithDescendants() >= child_sizes + it->GetTxSize());
692 waitingOnDependants.push_back(&(*it));
694 CheckInputsAndUpdateCoins(tx, mempoolDuplicate, spendheight);
697 unsigned int stepsSinceLastRemove = 0;
698 while (!waitingOnDependants.empty()) {
700 waitingOnDependants.pop_front();
702 waitingOnDependants.push_back(entry);
703 stepsSinceLastRemove++;
704 assert(stepsSinceLastRemove < waitingOnDependants.size());
706 CheckInputsAndUpdateCoins(entry->
GetTx(), mempoolDuplicate, spendheight);
707 stepsSinceLastRemove = 0;
710 for (
auto it = mapNextTx.cbegin(); it != mapNextTx.cend(); it++) {
711 uint256 hash = it->second->GetHash();
712 indexed_transaction_set::const_iterator it2 = mapTx.find(hash);
714 assert(it2 != mapTx.end());
715 assert(&tx == it->second);
725 indexed_transaction_set::const_iterator i = mapTx.find(hasha);
726 if (i == mapTx.end())
return false;
727 indexed_transaction_set::const_iterator j = mapTx.find(hashb);
728 if (j == mapTx.end())
return true;
729 uint64_t counta = i->GetCountWithAncestors();
730 uint64_t countb = j->GetCountWithAncestors();
731 if (counta == countb) {
734 return counta < countb;
738 class DepthAndScoreComparator
741 bool operator()(
const CTxMemPool::indexed_transaction_set::const_iterator& a,
const CTxMemPool::indexed_transaction_set::const_iterator& b)
743 uint64_t counta = a->GetCountWithAncestors();
744 uint64_t countb = b->GetCountWithAncestors();
745 if (counta == countb) {
748 return counta < countb;
755 std::vector<indexed_transaction_set::const_iterator> iters;
758 iters.reserve(mapTx.size());
760 for (indexed_transaction_set::iterator mi = mapTx.begin(); mi != mapTx.end(); ++mi) {
763 std::sort(iters.begin(), iters.end(), DepthAndScoreComparator());
773 vtxid.reserve(mapTx.size());
775 for (
auto it : iters) {
776 vtxid.push_back(it->GetTx().GetHash());
780 static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
781 return TxMempoolInfo{it->GetSharedTx(), it->GetTime(),
CFeeRate(it->GetFee(), it->GetTxSize()), it->GetModifiedFee() - it->
GetFee()};
789 std::vector<TxMempoolInfo>
ret;
790 ret.reserve(mapTx.size());
791 for (
auto it : iters) {
801 indexed_transaction_set::const_iterator i = mapTx.find(hash);
802 if (i == mapTx.end())
804 return i->GetSharedTx();
810 indexed_transaction_set::const_iterator i = mapTx.find(hash);
811 if (i == mapTx.end())
822 txiter it = mapTx.find(hash);
823 if (it != mapTx.end()) {
827 uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
830 for (
txiter ancestorIt : setAncestors) {
836 setDescendants.erase(it);
837 for (
txiter descendantIt : setDescendants) {
843 LogPrintf(
"PrioritiseTransaction: %s feerate += %s\n", hash.
ToString(),
FormatMoney(nFeeDelta));
849 std::map<uint256, CAmount>::const_iterator pos =
mapDeltas.find(hash);
852 const CAmount &delta = pos->second;
864 const auto it = mapNextTx.find(prevout);
865 return it == mapNextTx.end() ? nullptr : it->second;
870 auto it = mapTx.find(txid);
871 if (it != mapTx.end())
return it;
872 return boost::optional<txiter>{};
878 for (
const auto& h : hashes) {
880 if (mi)
ret.insert(*mi);
887 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
901 if (outpoint.
n < ptx->vout.size()) {
902 coin =
Coin(ptx->vout[outpoint.
n], MEMPOOL_HEIGHT,
false);
927 indexed_transaction_set::index<entry_time>::type::iterator it = mapTx.get<
entry_time>().begin();
929 while (it != mapTx.get<
entry_time>().end() && it->GetTime() < time) {
930 toremove.insert(mapTx.project<0>(it));
934 for (
txiter removeit : toremove) {
944 uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
947 return addUnchecked(entry, setAncestors, validFeeEstimate);
953 if (add &&
mapLinks[entry].children.insert(child).second) {
955 }
else if (!add &&
mapLinks[entry].children.erase(child)) {
963 if (add &&
mapLinks[entry].parents.insert(parent).second) {
965 }
else if (!add &&
mapLinks[entry].parents.erase(parent)) {
972 assert (entry != mapTx.end());
973 txlinksMap::const_iterator it =
mapLinks.find(entry);
975 return it->second.parents;
980 assert (entry != mapTx.end());
981 txlinksMap::const_iterator it =
mapLinks.find(entry);
983 return it->second.children;
1021 unsigned nTxnRemoved = 0;
1024 indexed_transaction_set::index<descendant_score>::type::iterator it = mapTx.get<
descendant_score>().begin();
1030 CFeeRate removed(it->GetModFeesWithDescendants(), it->GetSizeWithDescendants());
1033 maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed);
1037 nTxnRemoved += stage.size();
1039 std::vector<CTransaction> txn;
1040 if (pvNoSpendsRemaining) {
1041 txn.reserve(stage.size());
1042 for (
txiter iter : stage)
1043 txn.push_back(iter->GetTx());
1046 if (pvNoSpendsRemaining) {
1050 pvNoSpendsRemaining->push_back(txin.
prevout);
1056 if (maxFeeRateRemoved >
CFeeRate(0)) {
1057 LogPrint(
BCLog::MEMPOOL,
"Removed %u txn, rolling minimum fee bumped to %s\n", nTxnRemoved, maxFeeRateRemoved.
ToString());
1063 std::vector<txiter> candidates;
1065 candidates.push_back(entry);
1066 uint64_t maximum = 0;
1067 while (candidates.size()) {
1068 txiter candidate = candidates.back();
1069 candidates.pop_back();
1070 if (!counted.insert(candidate).second)
continue;
1072 if (parents.size() == 0) {
1073 maximum = std::max(maximum, candidate->GetCountWithDescendants());
1075 for (
txiter i : parents) {
1076 candidates.push_back(i);
1085 auto it = mapTx.find(txid);
1086 ancestors = descendants = 0;
1087 if (it != mapTx.end()) {
1088 ancestors = it->GetCountWithAncestors();
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost)
Compute the virtual transaction size (weight reinterpreted as bytes).
Information about a mempool transaction.
int Expire(int64_t time)
Expire all transaction (and their dependencies) in the mempool older than time.
CAmount nModFeesWithDescendants
... and total fees (all including us)
void UpdateLockPoints(const LockPoints &lp)
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
virtual bool GetCoin(const COutPoint &outpoint, Coin &coin) const
Retrieve the Coin (unspent transaction output) for a given outpoint.
std::vector< TxMempoolInfo > infoAll() const
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or a pruned one if not found.
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason=MemPoolRemovalReason::UNKNOWN)
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
boost::signals2::signal< void(CTransactionRef)> NotifyEntryAdded
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of hash.
size_t DynamicMemoryUsage() const
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
bool removeTx(uint256 hash, bool inBlock)
Remove a transaction from the mempool tracking stats.
reverse_range< T > reverse_iterate(T &x)
UniValue ret(UniValue::VARR)
TxMempoolInfo info(const uint256 &hash) const
Removed in size limiting.
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
CTxMemPool(CBlockPolicyEstimator *estimator=nullptr)
Create a new CTxMemPool.
bool HasNoInputsOf(const CTransaction &tx) const
Check that none of this transactions inputs are in the mempool, and thus the tx is not dependent on o...
std::set< txiter, CompareIteratorByHash > setEntries
void queryHashes(std::vector< uint256 > &vtxid)
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal...
void TrimToSize(size_t sizelimit, std::vector< COutPoint > *pvNoSpendsRemaining=nullptr)
Remove transactions from the mempool until its dynamic size is <= sizelimit.
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps)
bool HaveInputs(const CTransaction &tx) const
Check whether all prevouts of the transaction are present in the UTXO set represented by this view...
bool CheckSequenceLocks(const CTxMemPool &pool, const CTransaction &tx, int flags, LockPoints *lp, bool useExistingLockPoints)
Check if transaction will be BIP 68 final in the next block to be created.
std::shared_ptr< const CTransaction > CTransactionRef
uint64_t nCountWithDescendants
number of descendant transactions
int64_t lastRollingFeeUpdate
bool isSpent(const COutPoint &outpoint) const
const std::vector< CTxIn > vin
void UpdateTransactionsFromBlock(const std::vector< uint256 > &vHashesToUpdate)
When adding transactions from a disconnected block back to the mempool, new mempool entries may have ...
void RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason=MemPoolRemovalReason::UNKNOWN) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove a set of transactions from the mempool.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
void check(const CCoinsViewCache *pcoins) const
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs)
Update ancestors of hash to add/remove it as a descendant transaction.
int64_t CAmount
Amount in satoshis (Can be negative)
bool blockSinceLastRollingFeeBump
#define AssertLockHeld(cs)
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
Removed for reorganization.
int64_t nSigOpCostWithAncestors
const size_t nTxWeight
... and avoid recomputing tx weight (also used for GetTxSize())
std::vector< std::pair< uint256, txiter > > vTxHashes
All tx witness hashes/entries in mapTx, in random order.
bool push_back(const UniValue &val)
void UpdateFeeDelta(int64_t feeDelta)
bool CheckFinalTx(const CTransaction &tx, int flags)
Transaction validation functions.
int GetSpendHeight(const CCoinsViewCache &inputs)
Return the spend height, which is one more than the inputs.GetBestBlock().
void removeUnchecked(txiter entry, MemPoolRemovalReason reason=MemPoolRemovalReason::UNKNOWN) EXCLUSIVE_LOCKS_REQUIRED(cs)
Before calling removeUnchecked for a given transaction, UpdateForRemoveFromMempool must be called on ...
uint64_t nSizeWithAncestors
int64_t feeDelta
Used for determining the priority of the transaction for mining in a block.
Abstract view on the open txout dataset.
size_t DynamicMemoryUsage() const
void ApplyDelta(const uint256 hash, CAmount &nFeeDelta) const
bool exists(const uint256 &hash) const
An input of a transaction.
const uint256 & GetWitnessHash() const
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
bool CheckTxInputs(const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight, CAmount &txfee)
Check whether all inputs of this transaction are valid (no double spends and amounts) This does not m...
const uint256 & GetHash() const
Removed for conflict with in-block transaction.
CTransactionRef GetSharedTx() const
void UpdateParent(txiter entry, txiter parent, bool add)
std::map< uint256, CAmount > mapDeltas
const std::vector< CTxOut > vout
uint64_t cachedInnerUsage
sum of dynamic memory usage of all the map elements (NOT the maps themselves)
static const int ROLLING_FEE_HALFLIFE
bool TestLockPointValidity(const LockPoints *lp)
Test whether the LockPoints height and time are still valid on the current chain. ...
CAmount nModFeesWithAncestors
std::string ToString() const
const setEntries & GetMemPoolChildren(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
unsigned int nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
const CTransaction * GetConflictTx(const COutPoint &prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Get the transaction in the pool that spends the same prevout.
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.
An outpoint - a combination of a transaction hash and an index n into its vout.
uint64_t nSizeWithDescendants
... and size
void AddTransactionsUpdated(unsigned int n)
CFeeRate GetMinFee(size_t sizelimit) const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
uint64_t totalTxSize
sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discount...
uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
const int64_t sigOpCost
Total sigop cost.
Capture information about block/transaction validation.
std::vector< indexed_transaction_set::const_iterator > GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
bool CompareDepthAndScore(const uint256 &hasha, const uint256 &hashb)
void processBlock(unsigned int nBlockHeight, std::vector< const CTxMemPoolEntry *> &entries)
Process all the transactions that have been included in a block.
std::map< txiter, setEntries, CompareIteratorByHash > cacheMap
LockPoints lockPoints
Track the height and time at which tx was final.
void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount)
const CTransaction & GetTx() const
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs)
void UpdateEntryForAncestors(txiter it, const setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs)
Set ancestor state for an entry.
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. ...
boost::optional< txiter > GetIter(const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given hash, if found.
uint64_t nCountWithAncestors
Fee rate in satoshis per kilobyte: CAmount / kB.
void UpdateChild(txiter entry, txiter child, bool add)
unsigned int GetTransactionsUpdated() const
const CAmount nFee
Cached to avoid expensive parent-transaction lookups.
const setEntries & GetMemPoolParents(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
void ClearPrioritisation(const uint256 hash)
CTransactionRef get(const uint256 &hash) const
boost::signals2::signal< void(CTransactionRef, MemPoolRemovalReason)> NotifyEntryRemoved
void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs)
void removeForBlock(const std::vector< CTransactionRef > &vtx, unsigned int nBlockHeight)
Called when a block is connected.
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn)
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
std::string ToString() const
The basic transaction that is broadcasted on the network and contained in blocks. ...
CCoinsView backed by another CCoinsView.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Sort by feerate of entry (fee/size) in descending order This is only used for transaction relay...
const CTxMemPool & mempool
void UpdateChildrenForRemoval(txiter entry) EXCLUSIVE_LOCKS_REQUIRED(cs)
Sever link between specified transaction and direct children.
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...
CBlockPolicyEstimator * minerPolicyEstimator
double rollingMinimumFeeRate
minimum fee to get into the pool, decreases exponentially
CFeeRate incrementalRelayFee
CTxMemPoolEntry(const CTransactionRef &_tx, const CAmount &_nFee, int64_t _nTime, unsigned int _entryHeight, bool spendsCoinbase, int64_t nSigOpsCost, LockPoints lp)
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
void addUnchecked(const CTxMemPoolEntry &entry, bool validFeeEstimate=true) EXCLUSIVE_LOCKS_REQUIRED(cs)
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
void UpdateForRemoveFromMempool(const setEntries &entriesToRemove, bool updateDescendants) EXCLUSIVE_LOCKS_REQUIRED(cs)
For each transaction being removed, update ancestors and any direct children.
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
void GetTransactionAncestry(const uint256 &txid, size_t &ancestors, size_t &descendants) const
Calculate the ancestor and descendant count for the given transaction.
uint64_t GetRand(uint64_t nMax)
void processTransaction(const CTxMemPoolEntry &entry, bool validFeeEstimate)
Process a transaction accepted to the mempool.
CAmount GetFee(size_t nBytes) const
Return the fee in satoshis for the given size in bytes.
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.