27 int64_t _nTime,
unsigned int _entryHeight,
28 bool _spendsCoinbaseOrCoinstake,
unsigned int _sigOps) :
29 tx(MakeTransactionRef(_tx)), nFee(_nFee), nTime(_nTime), entryHeight(_entryHeight),
30 spendsCoinbaseOrCoinstake(_spendsCoinbaseOrCoinstake), sigOpCount(_sigOps)
64 while (!stageEntries.empty()) {
65 const txiter cit = *stageEntries.begin();
66 setAllDescendants.insert(cit);
67 stageEntries.erase(cit);
69 for (
const txiter& childEntry : setChildren) {
70 cacheMap::iterator cacheIt = cachedDescendants.find(childEntry);
71 if (cacheIt != cachedDescendants.end()) {
74 for (
const 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 (
const txiter& cit : setAllDescendants) {
89 if (!setExclude.count(cit->GetTx().GetHash())) {
90 modifySize += cit->GetTxSize();
91 modifyFee += cit->GetModifiedFee();
93 cachedDescendants[updateIt].insert(cit);
112 cacheMap mapMemPoolDescendantsToUpdate;
116 std::set<uint256> setAlreadyIncluded(vHashesToUpdate.begin(), vHashesToUpdate.end());
128 if (it ==
mapTx.end()) {
134 for (; iter !=
mapNextTx.
end() && iter->first->hash == hash; ++iter) {
135 const uint256 &childHash = iter->second->GetHash();
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 txiter piter =
mapTx.find(tx->vin[i].prevout.hash);
160 if (piter !=
mapTx.end()) {
161 parentHashes.insert(piter);
162 if (parentHashes.size() + 1 > limitAncestorCount) {
163 errString =
strprintf(
"too many unconfirmed parents [limit: %u]", limitAncestorCount);
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 (
const 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 (
const 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 (
const txiter& ancestorIt : setAncestors) {
228 int64_t updateCount = setAncestors.size();
229 int64_t updateSize = 0;
231 int updateSigOps = 0;
232 for (
const txiter& ancestorIt : setAncestors) {
233 updateSize += ancestorIt->GetTxSize();
234 updateFee += ancestorIt->GetModifiedFee();
235 updateSigOps += ancestorIt->GetSigOpCount();
243 for (
const txiter& updateIt : setMemPoolChildren) {
252 const uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
253 if (updateDescendants) {
260 for (
const txiter& removeIt : entriesToRemove) {
263 setDescendants.erase(removeIt);
264 int64_t modifySize = -((int64_t)removeIt->GetTxSize());
265 CAmount modifyFee = -removeIt->GetModifiedFee();
266 int modifySigOps = -removeIt->GetSigOpCount();
267 for (
const txiter& dit : setDescendants) {
272 for (
const txiter& removeIt : entriesToRemove) {
301 for (
const txiter& removeIt : entriesToRemove) {
327 nTransactionsUpdated(0)
372 case CTransaction::TxType::PROREG: {
386 case CTransaction::TxType::PROUPSERV: {
395 case CTransaction::TxType::PROUPREG: {
404 case CTransaction::TxType::PROUPREV: {
420 indexed_transaction_set::iterator newit =
mapTx.insert(entry).first;
426 std::map<uint256, CAmount>::const_iterator pos =
mapDeltas.find(hash);
428 const CAmount &delta = pos->second;
440 std::set<uint256> setParentTransactions;
442 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
444 setParentTransactions.insert(tx.
vin[i].prevout.hash);
455 for (
const uint256& phash : setParentTransactions) {
457 if (pit !=
mapTx.end()) {
486 for (
auto it = its.first; it != its.second;) {
487 if (it->second == txHash) {
497 case CTransaction::TxType::PROREG: {
511 case CTransaction::TxType::PROUPSERV: {
520 case CTransaction::TxType::PROUPREG: {
529 case CTransaction::TxType::PROUPREV: {
581 if (setDescendants.count(entryit) == 0) {
582 stage.insert(entryit);
587 while (!stage.empty()) {
588 txiter it = *stage.begin();
589 setDescendants.insert(it);
593 for (
const txiter& childiter : setChildren) {
594 if (!setDescendants.count(childiter)) {
595 stage.insert(childiter);
608 if (origit !=
mapTx.end()) {
609 txToRemove.insert(origit);
615 for (
unsigned int i = 0; i < origTx.
vout.size(); i++) {
620 assert(nextit !=
mapTx.end());
621 txToRemove.insert(nextit);
625 for (
const txiter& it : txToRemove) {
639 for (indexed_transaction_set::const_iterator it =
mapTx.begin(); it !=
mapTx.end(); it++) {
642 txToRemove.insert(it);
643 }
else if (it->GetSpendsCoinbaseOrCoinstake()) {
644 for (
const CTxIn& txin : tx->vin) {
645 indexed_transaction_set::const_iterator it2 =
mapTx.find(txin.
prevout.
hash);
646 if (it2 !=
mapTx.end())
651 txToRemove.insert(it);
658 for (
txiter it : txToRemove) {
672 std::list<CTransaction> transactionsToRemove;
673 for (indexed_transaction_set::const_iterator it =
mapTx.begin(); it !=
mapTx.end(); it++) {
676 for (
const auto& sd : tx.
sapData->vShieldedSpend) {
677 if (sd.anchor == invalidRoot) {
678 transactionsToRemove.emplace_back(tx);
691 std::list<CTransaction> result;
697 if (txConflict != tx) {
709 if (txConflict != tx) {
722 if (conflictHash != tx.
GetHash() &&
mapTx.count(conflictHash)) {
732 if (conflictHash != tx.
GetHash() &&
mapTx.count(conflictHash)) {
742 if (conflictHash != tx.
GetHash() &&
mapTx.count(conflictHash)) {
756 auto conflictIt =
mapTx.find(it->second);
757 if (conflictIt !=
mapTx.end()) {
762 LogPrint(
BCLog::MEMPOOL,
"%s: ERROR: found invalid TX ref in mapProTxRefs, proTxHash=%s, txHash=%s\n", __func__,
proTxHash.ToString(), it->second.ToString());
771 for (
const auto& in : tx.
vin) {
777 auto dmn = mnList.GetMNByCollateral(in.prevout);
793 case CTransaction::TxType::PROREG: {
801 if (conflictHash != txid &&
mapTx.count(conflictHash)) {
813 case CTransaction::TxType::PROUPSERV: {
821 if (conflictHash != txid &&
mapTx.count(conflictHash)) {
828 case CTransaction::TxType::PROUPREG: {
847 std::vector<const CTxMemPoolEntry*> entries;
848 for (
const auto& tx : vtx) {
850 indexed_transaction_set::iterator i =
mapTx.find(hash);
851 if (i !=
mapTx.end())
852 entries.push_back(&*i);
856 for (
const auto& tx : vtx) {
858 if (it !=
mapTx.end()) {
903 uint64_t checkTotal = 0;
904 uint64_t innerUsage = 0;
909 std::list<const CTxMemPoolEntry*> waitingOnDependants;
910 for (indexed_transaction_set::const_iterator it =
mapTx.begin(); it !=
mapTx.end(); it++) {
912 checkTotal += it->GetTxSize();
913 innerUsage += it->DynamicMemoryUsage();
915 txlinksMap::const_iterator linksiter =
mapLinks.find(it);
916 assert(linksiter !=
mapLinks.end());
917 const TxLinks &links = linksiter->second;
918 innerUsage += memusage::DynamicUsage(links.
parents) + memusage::DynamicUsage(links.
children);
919 bool fDependsWait =
false;
921 int64_t parentSizes = 0;
922 unsigned int parentSigOpCount = 0;
925 indexed_transaction_set::const_iterator it2 =
mapTx.find(txin.
prevout.
hash);
926 if (it2 !=
mapTx.end()) {
930 if (setParentCheck.insert(it2).second) {
931 parentSizes += it2->GetTxSize();
932 parentSigOpCount += it2->GetSigOpCount();
940 assert(it3->first == &txin.
prevout);
941 assert(*it3->second == tx);
955 uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
958 uint64_t nCountCheck = setAncestors.size() + 1;
959 uint64_t nSizeCheck = it->GetTxSize();
960 CAmount nFeesCheck = it->GetModifiedFee();
961 unsigned int nSigOpCheck = it->GetSigOpCount();
963 for (
const txiter& ancestorIt : setAncestors) {
964 nSizeCheck += ancestorIt->GetTxSize();
965 nFeesCheck += ancestorIt->GetModifiedFee();
966 nSigOpCheck += ancestorIt->GetSigOpCount();
969 assert(it->GetCountWithAncestors() == nCountCheck);
970 assert(it->GetSizeWithAncestors() == nSizeCheck);
971 assert(it->GetSigOpCountWithAncestors() == nSigOpCheck);
972 assert(it->GetModFeesWithAncestors() == nFeesCheck);
977 int64_t childSizes = 0;
979 txiter childit =
mapTx.find(iter->second->GetHash());
980 assert(childit !=
mapTx.end());
981 if (setChildrenCheck.insert(childit).second) {
982 childSizes += childit->GetTxSize();
988 assert(it->GetSizeWithDescendants() >= (uint64_t)(childSizes + it->GetTxSize()));
992 waitingOnDependants.push_back(&(*it));
996 assert(
CheckInputs(tx, state, mempoolDuplicate,
false, 0,
false, precomTxData,
nullptr));
1001 unsigned int stepsSinceLastRemove = 0;
1002 while (!waitingOnDependants.empty()) {
1004 waitingOnDependants.pop_front();
1007 waitingOnDependants.push_back(entry);
1008 stepsSinceLastRemove++;
1009 assert(stepsSinceLastRemove < waitingOnDependants.size());
1012 assert(
CheckInputs(entry->
GetTx(), state, mempoolDuplicate,
false, 0,
false, precomTxData,
nullptr));
1014 stepsSinceLastRemove = 0;
1018 const uint256& hash = it->second->GetHash();
1019 indexed_transaction_set::const_iterator it2 =
mapTx.find(hash);
1021 assert(it2 !=
mapTx.end());
1022 assert(tx == it->second);
1035 const uint256& hash = it.second->GetHash();
1036 const auto& findTx =
mapTx.find(hash);
1037 assert(findTx !=
mapTx.end());
1039 assert(*tx == *it.second);
1046 indexed_transaction_set::const_iterator i =
mapTx.find(hasha);
1047 if (i ==
mapTx.end())
return false;
1048 indexed_transaction_set::const_iterator j =
mapTx.find(hashb);
1049 if (j ==
mapTx.end())
return true;
1050 uint64_t counta = i->GetCountWithAncestors();
1051 uint64_t countb = j->GetCountWithAncestors();
1052 if (counta == countb) {
1055 return counta < countb;
1059 class DepthAndScoreComparator
1062 bool operator()(
const CTxMemPool::indexed_transaction_set::const_iterator& a,
const CTxMemPool::indexed_transaction_set::const_iterator& b)
const
1064 uint64_t counta = a->GetCountWithAncestors();
1065 uint64_t countb = b->GetCountWithAncestors();
1066 if (counta == countb) {
1069 return counta < countb;
1076 std::vector<indexed_transaction_set::const_iterator> iters;
1079 iters.reserve(
mapTx.size());
1081 for (indexed_transaction_set::iterator mi =
mapTx.begin(); mi !=
mapTx.end(); ++mi) {
1082 iters.push_back(mi);
1084 std::sort(iters.begin(), iters.end(), DepthAndScoreComparator());
1094 vtxid.reserve(
mapTx.size());
1096 for (
auto it : iters) {
1097 vtxid.emplace_back(it->GetTx().GetHash());
1101 static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
1102 return TxMempoolInfo{it->GetSharedTx(), it->GetTime(),
CFeeRate(it->GetFee(), it->GetTxSize()), it->GetModifiedFee() - it->
GetFee()};
1110 std::vector<TxMempoolInfo> ret;
1111 ret.reserve(
mapTx.size());
1112 for (
auto it : iters) {
1113 ret.emplace_back(GetInfo(it));
1124 for (indexed_transaction_set::iterator mi =
mapTx.begin(); mi !=
mapTx.end(); ++mi)
1125 setTxid.insert(mi->GetTx().GetHash());
1131 indexed_transaction_set::const_iterator i =
mapTx.find(hash);
1132 if (i ==
mapTx.end())
1134 return i->GetSharedTx();
1140 indexed_transaction_set::const_iterator i =
mapTx.find(hash);
1141 if (i ==
mapTx.end())
1153 case CTransaction::TxType::PROREG: {
1176 case CTransaction::TxType::PROUPSERV: {
1186 case CTransaction::TxType::PROUPREG: {
1217 fileout << CLIENT_VERSION;
1219 }
catch (
const std::exception&) {
1220 LogPrintf(
"CTxMemPool::WriteFeeEstimates() : unable to write policy estimator data (non-fatal)\n");
1229 int nVersionRequired, nVersionThatWrote;
1230 filein >> nVersionRequired >> nVersionThatWrote;
1231 if (nVersionRequired > CLIENT_VERSION)
1232 return error(
"CTxMemPool::ReadFeeEstimates() : up-version (%d) fee estimate file\n", nVersionRequired);
1236 }
catch (
const std::exception&) {
1237 LogPrintf(
"CTxMemPool::ReadFeeEstimates() : unable to read policy estimator data (non-fatal)\n");
1250 if (it !=
mapTx.end()) {
1254 uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
1257 for (
const txiter& ancestorIt : setAncestors) {
1262 LogPrintf(
"PrioritiseTransaction: %s feerate += %s\n", hash.
ToString(),
FormatMoney(nFeeDelta));
1268 std::map<uint256, CAmount>::const_iterator pos =
mapDeltas.find(hash);
1271 const CAmount &delta = pos->second;
1291 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
1307 if (outpoint.
n < ptx->vout.size()) {
1308 coin =
Coin(ptx->vout[outpoint.
n], MEMPOOL_HEIGHT,
false,
false);
1344 for (
const txiter& it : stage) {
1352 indexed_transaction_set::index<entry_time>::type::iterator it =
mapTx.get<
entry_time>().begin();
1355 toremove.insert(
mapTx.project<0>(it));
1359 for (
const txiter& removeit : toremove) {
1363 return stage.size();
1370 uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
1373 return addUnchecked(hash, entry, setAncestors, validFeeEstimate);
1379 if (add &&
mapLinks[entry].children.insert(child).second) {
1381 }
else if (!add &&
mapLinks[entry].children.erase(child)) {
1389 if (add &&
mapLinks[entry].parents.insert(parent).second) {
1391 }
else if (!add &&
mapLinks[entry].parents.erase(parent)) {
1398 assert (entry !=
mapTx.end());
1399 txlinksMap::const_iterator it =
mapLinks.find(entry);
1401 return it->second.parents;
1406 assert (entry !=
mapTx.end());
1407 txlinksMap::const_iterator it =
mapLinks.find(entry);
1409 return it->second.children;
1449 unsigned nTxnRemoved = 0;
1452 indexed_transaction_set::index<descendant_score>::type::iterator it =
mapTx.get<
descendant_score>().begin();
1458 CFeeRate removed(it->GetModFeesWithDescendants(), it->GetSizeWithDescendants());
1461 maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed);
1465 nTxnRemoved += stage.size();
1467 std::vector<CTransaction> txn;
1468 if (pvNoSpendsRemaining) {
1469 txn.reserve(stage.size());
1471 txn.push_back(it->GetTx());
1474 if (pvNoSpendsRemaining) {
1476 for (
const CTxIn& txin: tx.vin) {
1479 pvNoSpendsRemaining->push_back(txin.
prevout);
1486 if (maxFeeRateRemoved >
CFeeRate(0))
1492 auto it =
mapTx.find(txid);
1493 return it ==
mapTx.end() || (it->GetCountWithAncestors() < chainLimit &&
1494 it->GetCountWithDescendants() < chainLimit);
1506 m_is_loaded = loaded;
int64_t CAmount
Amount in PIV (Can be negative)
const CChainParams & Params()
Return the currently selected parameters.
Non-refcounted RAII wrapper for FILE*.
const uint256 & GetHash() const
We want to be able to estimate feerates or priorities that are needed on tx's to be included in a cer...
bool removeTx(const uint256 &hash)
Remove a transaction from the mempool tracking stats.
void Write(CAutoFile &fileout)
Write estimation data to a file.
CFeeRate estimateFee(int confTarget)
Return a feerate estimate.
void Read(CAutoFile &filein, int nFileVersion)
Read estimation data from a file.
CFeeRate estimateSmartFee(int confTarget, int *answerFoundAtTarget, const CTxMemPool &pool)
Estimate feerate needed to get be included in a block within confTarget blocks.
void processTransaction(const CTxMemPoolEntry &entry, bool validFeeEstimate)
Process a transaction accepted to the mempool.
void processBlock(unsigned int nBlockHeight, std::vector< const CTxMemPoolEntry * > &entries)
Process all the transactions that have been included in a block.
CCoinsView backed by another CCoinsView.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
bool HaveInputs(const CTransaction &tx) const
Check whether all prevouts of the transaction are present in the UTXO set represented by this view.
bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const override
Retrieve the tree (Sapling) at a particular anchored root in the chain.
bool GetNullifier(const uint256 &nullifier) const override
Determine whether a nullifier is spent or not.
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether we have data for a given outpoint.
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to a Coin in the cache, or a pruned one if not found.
Abstract view on the open txout dataset.
virtual bool GetCoin(const COutPoint &outpoint, Coin &coin) const
Retrieve the Coin (unspent transaction output) for a given outpoint.
virtual bool GetNullifier(const uint256 &nullifier) const
Determine whether a nullifier is spent or not.
virtual bool HaveCoin(const COutPoint &outpoint) const
Just check whether we have data for a given outpoint.
bool HaveCoin(const COutPoint &outpoint) const
Just check whether we have data for a given outpoint.
bool GetCoin(const COutPoint &outpoint, Coin &coin) const
Retrieve the Coin (unspent transaction output) for a given outpoint.
bool GetNullifier(const uint256 &nullifier) const
Determine whether a nullifier is spent or not.
CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn)
Fee rate in PIV per kilobyte: CAmount / kB.
std::string ToString() const
CAmount GetFee(size_t size) const
CAmount GetFeePerK() const
A reference to a CKey: the Hash160 of its serialized public key.
void TransactionRemovedFromMempool(const CTransactionRef &, MemPoolRemovalReason)
An outpoint - a combination of a transaction hash and an index n into its vout.
The basic transaction that is broadcasted on the network and contained in blocks.
bool HasZerocoinSpendInputs() const
bool IsShieldedTx() const
const uint256 & GetHash() const
std::string ToString() const
Optional< SaplingTxData > sapData
std::vector< CTxOut > vout
An input of a transaction.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
void UpdateFeeDelta(int64_t feeDelta)
size_t nTxSize
Cached to avoid expensive parent-transaction lookups.
const CTransaction & GetTx() const
int64_t feeDelta
Legacy sig ops plus P2SH sig op count.
void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount)
size_t nUsageSize
... and avoid recomputing tx size
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int modifySigOps)
CAmount nModFeesWithAncestors
unsigned int nSigOpCountWithAncestors
bool hasZerocoins
... and fee per kB
uint64_t nCountWithDescendants
Used for determining the priority of the transaction for mining in a block.
unsigned int sigOpCount
keep track of transactions that spend a coinbase or a coinstake
bool m_isShielded
... and checking if it contains zPIV (mints/spends)
std::shared_ptr< const CTransaction > GetSharedTx() const
uint64_t nSizeWithDescendants
number of descendant transactions
CTxMemPoolEntry(const CTransactionRef &_tx, const CAmount &_nFee, int64_t _nTime, unsigned int _entryHeight, bool _spendsCoinbaseOrCoinstake, unsigned int nSigOps)
size_t DynamicMemoryUsage() const
CAmount nModFeesWithDescendants
... and size
uint64_t nCountWithAncestors
... and total fees (all including us)
uint64_t nSizeWithAncestors
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
bool TransactionWithinChainLimit(const uint256 &txid, size_t chainLimit) const
Returns false if the transaction is in the mempool and not within the chain limit specified.
bool ReadFeeEstimates(CAutoFile &filein)
const setEntries & GetMemPoolChildren(txiter entry) const
void ClearPrioritisation(const uint256 hash)
void removeWithAnchor(const uint256 &invalidRoot)
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason=MemPoolRemovalReason::UNKNOWN)
void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors)
Update ancestors of hash to add/remove it as a descendant transaction.
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
unsigned int nTransactionsUpdated
Value n means that n times in 2^32 we check.
std::map< uint256, CTransactionRef > mapSaplingNullifiers
CFeeRate GetMinFee(size_t sizelimit) const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
CTransactionRef get(const uint256 &hash) const
bool WriteFeeEstimates(CAutoFile &fileout) const
Write/Read estimates to disk.
std::map< CKeyID, uint256 > mapProTxPubKeyIDs
int Expire(int64_t time)
Expire all transaction (and their dependencies) in the mempool older than time.
void getTransactions(std::set< uint256 > &setTxid)
void AddTransactionsUpdated(unsigned int n)
CFeeRate estimateFee(int nBlocks) const
Estimate fee rate needed to get into the next nBlocks.
indirectmap< COutPoint, CTransactionRef > mapNextTx
void removeProTxReferences(const uint256 &proTxHash, MemPoolRemovalReason reason)
CFeeRate estimateSmartFee(int nBlocks, int *answerFoundAtBlocks=nullptr) const
Estimate fee rate needed to get into the next nBlocks If no answer can be given at nBlocks,...
double rollingMinimumFeeRate
void queryHashes(std::vector< uint256 > &vtxid)
std::vector< indexed_transaction_set::const_iterator > GetSortedDepthAndScore() const
void UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendants, const std::set< uint256 > &setExclude)
UpdateForDescendants is used by UpdateTransactionsFromBlock to update the descendants for a single tr...
void removeUnchecked(txiter entry, MemPoolRemovalReason reason=MemPoolRemovalReason::UNKNOWN)
Before calling removeUnchecked for a given transaction, UpdateForRemoveFromMempool must be called on ...
bool addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry, bool validFeeEstimate=true)
size_t DynamicMemoryUsage() const
std::vector< TxMempoolInfo > infoAll() const
void SetIsLoaded(bool loaded)
Sets the current loaded state.
int64_t lastRollingFeeUpdate
std::map< uint256, CAmount > mapDeltas
void trackPackageRemoved(const CFeeRate &rate)
minimum fee to get into the pool, decreases exponentially
void checkNullifiers() const
void addUncheckedSpecialTx(const CTransaction &tx)
Special txes.
void removeProTxPubKeyConflicts(const CTransaction &tx, const CKeyID &keyId)
CFeeRate minReasonableRelayFee
sum of dynamic memory usage of all the map elements (NOT the maps themselves)
void removeProTxCollateralConflicts(const CTransaction &tx, const COutPoint &collateralOutpoint)
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...
void UpdateForRemoveFromMempool(const setEntries &entriesToRemove, bool updateDescendants)
For each transaction being removed, update ancestors and any direct children.
void UpdateTransactionsFromBlock(const std::vector< uint256 > &hashesToUpdate)
When adding transactions from a disconnected block back to the mempool, new mempool entries may have ...
bool existsProviderTxConflict(const CTransaction &tx) const
bool CompareDepthAndScore(const uint256 &hasha, const uint256 &hashb)
void UpdateChildrenForRemoval(txiter entry)
Sever link between specified transaction and direct children.
void removeProTxConflicts(const CTransaction &tx)
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
Try to calculate all in-mempool ancestors of entry.
bool exists(uint256 hash) const
static const int ROLLING_FEE_HALFLIFE
std::set< txiter, CompareIteratorByHash > setEntries
void removeConflicts(const CTransaction &tx)
void UpdateChild(txiter entry, txiter child, bool add)
uint64_t cachedInnerUsage
sum of all mempool tx' byte sizes
indexed_transaction_set::nth_index< 0 >::type::iterator txiter
void removeUncheckedSpecialTx(const CTransaction &tx)
std::map< CService, uint256 > mapProTxAddresses
void check(const CCoinsViewCache *pcoins) const
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
std::multimap< uint256, uint256 > mapProTxRefs
std::map< txiter, setEntries, CompareIteratorByHash > cacheMap
CTxMemPool(const CFeeRate &_minReasonableRelayFee)
Create a new CTxMemPool.
const setEntries & GetMemPoolParents(txiter entry) const
uint64_t totalTxSize
Passed to constructor to avoid dependency on main.
void RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason=MemPoolRemovalReason::UNKNOWN)
Remove a set of transactions from the mempool.
indexed_transaction_set mapTx
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags)
TxMempoolInfo info(const uint256 &hash) const
std::map< uint256, uint256 > mapProTxBlsPubKeyHashes
void TrimToSize(size_t sizelimit, std::vector< COutPoint > *pvNoSpendsRemaining=nullptr)
Remove transactions from the mempool until its dynamic size is <= sizelimit.
bool isSpent(const COutPoint &outpoint)
void UpdateParent(txiter entry, txiter parent, bool add)
void CalculateDescendants(txiter it, setEntries &setDescendants)
Populate setDescendants with all in-mempool descendants of hash.
void UpdateEntryForAncestors(txiter it, const setEntries &setAncestors)
Set ancestor state for an entry.
void removeForBlock(const std::vector< CTransactionRef > &vtx, unsigned int nBlockHeight)
Called when a block is connected.
std::map< COutPoint, uint256 > mapProTxCollaterals
bool blockSinceLastRollingFeeBump
void removeProTxSpentCollateralConflicts(const CTransaction &tx)
CBlockPolicyEstimator * minerPolicyEstimator
bool nullifierExists(const uint256 &nullifier) const
void ApplyDelta(const uint256 &hash, CAmount &nFeeDelta) const
unsigned int GetTransactionsUpdated() const
Capture information about block/transaction validation.
uint32_t nHeight
at which height the containing transaction was included in the active block chain
Sort by score of entry ((fee+delta)/size) in descending order.
COutPoint collateralOutpoint
CBLSPublicKey pubKeyOperator
CBLSPublicKey pubKeyOperator
A shielded input to a transaction.
uint256 anchor
A Merkle root of the Sapling note commitment tree at some block height in the past.
uint256 nullifier
The nullifier of the input note.
std::string ToString() const
iterator lower_bound(const K &key)
const_iterator cbegin() const
std::pair< iterator, bool > insert(const value_type &value)
iterator find(const K &key)
const_iterator cend() const
size_type erase(const K &key)
size_type count(const K &key) const
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight, bool fSkipInvalid=false)
std::unique_ptr< CDeterministicMNManager > deterministicMNManager
#define LogPrint(category,...)
RecursiveMutex cs_main
Global state.
uint64_t GetRand(uint64_t nMax) noexcept
reverse_range< T > reverse_iterate(T &x)
unsigned int GetSerializeSize(const std::array< T, N > &item)
array
Information about a mempool transaction.
#define AssertLockHeld(cs)
bool error(const char *fmt, const Args &... args)
bool GetTxPayload(const std::vector< unsigned char > &payload, T &obj)
std::shared_ptr< const CTransaction > CTransactionRef
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
@ SIZELIMIT
Expired from mempool.
@ BLOCK
Removed for reorganization.
@ EXPIRY
Manually removed or unknown reason.
@ CONFLICT
Removed for block.
@ REORG
Removed in size limiting.
std::string FormatMoney(const CAmount &n, bool fPlus)
Money parsing/formatting utilities.
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
bool CheckFinalTx(const CTransactionRef &tx, int flags)
Check if transaction will be final in the next block to be created.
bool CheckInputs(const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheStore, PrecomputedTransactionData &precomTxData, std::vector< CScriptCheck > *pvChecks)
Check transaction inputs, and make sure any pay-to-script-hash transactions are evaluating IsStandard...
CTxMemPool mempool(::minRelayTxFee)
CMainSignals & GetMainSignals()