22 int64_t _nTime,
unsigned int _entryHeight,
24 tx(_tx), nFee(_nFee), nTime(_nTime), entryHeight(_entryHeight),
25 spendsCoinbase(_spendsCoinbase), sigOpCost(_sigOpsCost), lockPoints(lp),
26 nMinGasPrice(_nMinGasPrice)
52 feeDelta = newFeeDelta;
71 stageEntries = GetMemPoolChildren(updateIt);
73 while (!stageEntries.empty()) {
74 const txiter cit = *stageEntries.begin();
75 setAllDescendants.insert(cit);
76 stageEntries.erase(cit);
77 const setEntries &setChildren = GetMemPoolChildren(cit);
78 for (
const txiter childEntry : setChildren) {
79 cacheMap::iterator cacheIt = cachedDescendants.find(childEntry);
80 if (cacheIt != cachedDescendants.end()) {
83 for (
const txiter cacheEntry : cacheIt->second) {
84 setAllDescendants.insert(cacheEntry);
86 }
else if (!setAllDescendants.count(childEntry)) {
88 stageEntries.insert(childEntry);
94 int64_t modifySize = 0;
96 int64_t modifyCount = 0;
97 for (
txiter cit : setAllDescendants) {
98 if (!setExclude.count(cit->GetTx().GetHash())) {
99 modifySize += cit->GetTxSize();
100 modifyFee += cit->GetModifiedFee();
102 cachedDescendants[updateIt].insert(cit);
104 mapTx.modify(cit,
update_ancestor_state(updateIt->GetTxSize(), updateIt->GetModifiedFee(), 1, updateIt->GetSigOpCost()));
121 cacheMap mapMemPoolDescendantsToUpdate;
125 std::set<uint256> setAlreadyIncluded(vHashesToUpdate.begin(), vHashesToUpdate.end());
136 txiter it = mapTx.find(hash);
137 if (it == mapTx.end()) {
140 auto iter = mapNextTx.lower_bound(
COutPoint(hash, 0));
143 for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) {
144 const uint256 &childHash = iter->second->GetHash();
145 txiter childIter = mapTx.find(childHash);
146 assert(childIter != mapTx.end());
149 if (setChildren.insert(childIter).second && !setAlreadyIncluded.count(childHash)) {
150 UpdateChild(it, childIter,
true);
151 UpdateParent(childIter, it,
true);
154 UpdateForDescendants(it, mapMemPoolDescendantsToUpdate, setAlreadyIncluded);
165 if (fSearchForParents) {
169 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
170 txiter piter = mapTx.find(tx.
vin[i].prevout.hash);
171 if (piter != mapTx.end()) {
172 parentHashes.insert(piter);
173 if (parentHashes.size() + 1 > limitAncestorCount) {
174 errString =
strprintf(
"too many unconfirmed parents [limit: %u]", limitAncestorCount);
182 txiter it = mapTx.iterator_to(entry);
183 parentHashes = GetMemPoolParents(it);
186 size_t totalSizeWithAncestors = entry.
GetTxSize();
188 while (!parentHashes.empty()) {
189 txiter stageit = *parentHashes.begin();
191 setAncestors.insert(stageit);
192 parentHashes.erase(stageit);
193 totalSizeWithAncestors += stageit->GetTxSize();
195 if (stageit->GetSizeWithDescendants() + entry.
GetTxSize() > limitDescendantSize) {
196 errString =
strprintf(
"exceeds descendant size limit for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limitDescendantSize);
198 }
else if (stageit->GetCountWithDescendants() + 1 > limitDescendantCount) {
199 errString =
strprintf(
"too many descendants for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limitDescendantCount);
201 }
else if (totalSizeWithAncestors > limitAncestorSize) {
202 errString =
strprintf(
"exceeds ancestor size limit [limit: %u]", limitAncestorSize);
206 const setEntries & setMemPoolParents = GetMemPoolParents(stageit);
207 for (
const txiter &phash : setMemPoolParents) {
209 if (setAncestors.count(phash) == 0) {
210 parentHashes.insert(phash);
212 if (parentHashes.size() + setAncestors.size() + 1 > limitAncestorCount) {
213 errString =
strprintf(
"too many unconfirmed ancestors [limit: %u]", limitAncestorCount);
224 setEntries parentIters = GetMemPoolParents(it);
226 for (
txiter piter : parentIters) {
227 UpdateChild(piter, it, add);
229 const int64_t updateCount = (add ? 1 : -1);
230 const int64_t updateSize = updateCount * it->GetTxSize();
231 const CAmount updateFee = updateCount * it->GetModifiedFee();
232 for (
txiter ancestorIt : setAncestors) {
239 int64_t updateCount = setAncestors.size();
240 int64_t updateSize = 0;
242 int64_t updateSigOpsCost = 0;
243 for (
txiter ancestorIt : setAncestors) {
244 updateSize += ancestorIt->GetTxSize();
245 updateFee += ancestorIt->GetModifiedFee();
246 updateSigOpsCost += ancestorIt->GetSigOpCost();
253 const setEntries &setMemPoolChildren = GetMemPoolChildren(it);
254 for (
txiter updateIt : setMemPoolChildren) {
255 UpdateParent(updateIt, it,
false);
264 if (updateDescendants) {
271 for (
txiter removeIt : entriesToRemove) {
273 CalculateDescendants(removeIt, setDescendants);
274 setDescendants.erase(removeIt);
275 int64_t modifySize = -((int64_t)removeIt->GetTxSize());
276 CAmount modifyFee = -removeIt->GetModifiedFee();
277 int modifySigOps = -removeIt->GetSigOpCost();
278 for (
txiter dit : setDescendants) {
283 for (
txiter removeIt : entriesToRemove) {
304 CalculateMemPoolAncestors(entry, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy,
false);
307 UpdateAncestorsOf(
false, removeIt, setAncestors);
312 for (
txiter removeIt : entriesToRemove) {
313 UpdateChildrenForRemoval(removeIt);
338 nTransactionsUpdated(0), minerPolicyEstimator(estimator)
373 indexed_transaction_set::iterator newit =
mapTx.insert(entry).first;
379 std::map<uint256, CAmount>::const_iterator pos =
mapDeltas.find(hash);
381 const CAmount &delta = pos->second;
393 std::set<uint256> setParentTransactions;
394 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
396 setParentTransactions.insert(tx.
vin[i].prevout.hash);
406 for (
const uint256 &phash : setParentTransactions) {
408 if (pit !=
mapTx.end()) {
420 newit->vTxHashesIdx =
vTxHashes.size() - 1;
428 const uint256 hash = it->GetTx().GetHash();
429 for (
const CTxIn& txin : it->GetTx().vin)
434 vTxHashes[it->vTxHashesIdx].second->vTxHashesIdx = it->vTxHashesIdx;
459 if (setDescendants.count(entryit) == 0) {
460 stage.insert(entryit);
465 while (!stage.empty()) {
466 txiter it = *stage.begin();
467 setDescendants.insert(it);
471 for (
const txiter &childiter : setChildren) {
472 if (!setDescendants.count(childiter)) {
473 stage.insert(childiter);
486 if (origit !=
mapTx.end()) {
487 txToRemove.insert(origit);
493 for (
unsigned int i = 0; i < origTx.
vout.size(); i++) {
499 txToRemove.insert(nextit);
503 for (
txiter it : txToRemove) {
516 for (indexed_transaction_set::const_iterator it =
mapTx.begin(); it !=
mapTx.end(); it++) {
523 txToRemove.insert(it);
524 }
else if (it->GetSpendsCoinbase()) {
526 indexed_transaction_set::const_iterator it2 =
mapTx.find(txin.
prevout.
hash);
527 if (it2 !=
mapTx.end())
534 ( coin.
IsCoinBase() && ((((
signed long)nMemPoolHeight) - coin.
nHeight < COINBASE_MATURITY)
535 || ( coin.
nHeight < consensus.CoinbaseLock && coin.
nHeight != 2 && (
signed long)nMemPoolHeight - coin.
nHeight < consensus.CoinbaseLock )) )
537 txToRemove.insert(it);
547 for (
txiter it : txToRemove) {
561 if (txConflict != tx)
576 std::vector<const CTxMemPoolEntry*> entries;
577 for (
const auto& tx : vtx)
581 indexed_transaction_set::iterator i =
mapTx.find(hash);
582 if (i !=
mapTx.end())
583 entries.push_back(&*i);
587 for (
const auto& tx : vtx)
590 if (it !=
mapTx.end()) {
631 uint64_t checkTotal = 0;
632 uint64_t innerUsage = 0;
634 CCoinsViewCache mempoolDuplicate(const_cast<CCoinsViewCache*>(pcoins));
638 std::list<const CTxMemPoolEntry*> waitingOnDependants;
639 for (indexed_transaction_set::const_iterator it =
mapTx.begin(); it !=
mapTx.end(); it++) {
641 checkTotal += it->GetTxSize();
642 innerUsage += it->DynamicMemoryUsage();
644 txlinksMap::const_iterator linksiter =
mapLinks.find(it);
646 const TxLinks &links = linksiter->second;
647 innerUsage += memusage::DynamicUsage(links.parents) + memusage::DynamicUsage(links.children);
648 bool fDependsWait =
false;
650 int64_t parentSizes = 0;
651 int64_t parentSigOpCost = 0;
654 indexed_transaction_set::const_iterator it2 =
mapTx.find(txin.
prevout.
hash);
655 if (it2 !=
mapTx.end()) {
659 if (setParentCheck.insert(it2).second) {
660 parentSizes += it2->GetTxSize();
661 parentSigOpCost += it2->GetSigOpCost();
670 assert(it3->second == &tx);
679 uint64_t nCountCheck = setAncestors.size() + 1;
680 uint64_t nSizeCheck = it->GetTxSize();
681 CAmount nFeesCheck = it->GetModifiedFee();
682 int64_t nSigOpCheck = it->GetSigOpCost();
684 for (
txiter ancestorIt : setAncestors) {
685 nSizeCheck += ancestorIt->GetTxSize();
686 nFeesCheck += ancestorIt->GetModifiedFee();
687 nSigOpCheck += ancestorIt->GetSigOpCost();
690 assert(it->GetCountWithAncestors() == nCountCheck);
691 assert(it->GetSizeWithAncestors() == nSizeCheck);
692 assert(it->GetSigOpCostWithAncestors() == nSigOpCheck);
693 assert(it->GetModFeesWithAncestors() == nFeesCheck);
698 int64_t childSizes = 0;
699 for (; iter !=
mapNextTx.
end() && iter->first->hash == it->GetTx().GetHash(); ++iter) {
700 txiter childit =
mapTx.find(iter->second->GetHash());
702 if (setChildrenCheck.insert(childit).second) {
703 childSizes += childit->GetTxSize();
709 assert(it->GetSizeWithDescendants() >= childSizes + it->GetTxSize());
712 waitingOnDependants.push_back(&(*it));
721 unsigned int stepsSinceLastRemove = 0;
722 while (!waitingOnDependants.empty()) {
724 waitingOnDependants.pop_front();
727 waitingOnDependants.push_back(entry);
728 stepsSinceLastRemove++;
729 assert(stepsSinceLastRemove < waitingOnDependants.size());
735 stepsSinceLastRemove = 0;
739 uint256 hash = it->second->GetHash();
740 indexed_transaction_set::const_iterator it2 =
mapTx.find(hash);
743 assert(&tx == it->second);
753 indexed_transaction_set::const_iterator i =
mapTx.find(hasha);
754 if (i ==
mapTx.end())
return false;
755 indexed_transaction_set::const_iterator j =
mapTx.find(hashb);
756 if (j ==
mapTx.end())
return true;
757 uint64_t counta = i->GetCountWithAncestors();
758 uint64_t countb = j->GetCountWithAncestors();
759 if (counta == countb) {
762 return counta < countb;
766 class DepthAndScoreComparator
769 bool operator()(
const CTxMemPool::indexed_transaction_set::const_iterator&
a,
const CTxMemPool::indexed_transaction_set::const_iterator&
b)
771 uint64_t counta = a->GetCountWithAncestors();
772 uint64_t countb = b->GetCountWithAncestors();
773 if (counta == countb) {
776 return counta < countb;
783 std::vector<indexed_transaction_set::const_iterator> iters;
786 iters.reserve(
mapTx.size());
788 for (indexed_transaction_set::iterator mi =
mapTx.begin(); mi !=
mapTx.end(); ++mi) {
791 std::sort(iters.begin(), iters.end(), DepthAndScoreComparator());
801 vtxid.reserve(
mapTx.size());
803 for (
auto it : iters) {
804 vtxid.push_back(it->GetTx().GetHash());
808 static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
809 return TxMempoolInfo{it->GetSharedTx(), it->GetTime(),
CFeeRate(it->GetFee(), it->GetTxSize()), it->GetModifiedFee() - it->
GetFee()};
817 std::vector<TxMempoolInfo> ret;
818 ret.reserve(
mapTx.size());
819 for (
auto it : iters) {
820 ret.push_back(GetInfo(it));
829 indexed_transaction_set::const_iterator i =
mapTx.find(hash);
830 if (i ==
mapTx.end())
832 return i->GetSharedTx();
838 indexed_transaction_set::const_iterator i =
mapTx.find(hash);
839 if (i ==
mapTx.end())
851 if (it !=
mapTx.end()) {
858 for (
txiter ancestorIt : setAncestors) {
864 setDescendants.erase(it);
865 for (
txiter descendantIt : setDescendants) {
877 std::map<uint256, CAmount>::const_iterator pos =
mapDeltas.find(hash);
880 const CAmount &delta = pos->second;
892 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
906 if (outpoint.
n < ptx->vout.size()) {
907 coin =
Coin(ptx->vout[outpoint.
n], MEMPOOL_HEIGHT,
false);
923 return memusage::MallocUsage(
sizeof(
CTxMemPoolEntry) + 15 *
sizeof(
void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(mapLinks) + memusage::DynamicUsage(vTxHashes) + cachedInnerUsage;
928 UpdateForRemoveFromMempool(stage, updateDescendants);
929 for (
const txiter& it : stage) {
930 removeUnchecked(it, reason);
936 indexed_transaction_set::index<entry_time>::type::iterator it = mapTx.get<
entry_time>().begin();
938 while (it != mapTx.get<
entry_time>().end() && it->GetTime() < time) {
939 toremove.insert(mapTx.project<0>(it));
943 for (
txiter removeit : toremove) {
944 CalculateDescendants(removeit, stage);
956 CalculateMemPoolAncestors(entry, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy);
957 return addUnchecked(hash, entry, setAncestors, validFeeEstimate);
963 if (add && mapLinks[entry].children.insert(child).second) {
964 cachedInnerUsage += memusage::IncrementalDynamicUsage(s);
965 }
else if (!add && mapLinks[entry].children.erase(child)) {
966 cachedInnerUsage -= memusage::IncrementalDynamicUsage(s);
973 if (add && mapLinks[entry].parents.insert(parent).second) {
974 cachedInnerUsage += memusage::IncrementalDynamicUsage(s);
975 }
else if (!add && mapLinks[entry].parents.erase(parent)) {
976 cachedInnerUsage -= memusage::IncrementalDynamicUsage(s);
982 assert (entry != mapTx.end());
983 txlinksMap::const_iterator it = mapLinks.find(entry);
984 assert(it != mapLinks.end());
985 return it->second.parents;
990 assert (entry != mapTx.end());
991 txlinksMap::const_iterator it = mapLinks.find(entry);
992 assert(it != mapLinks.end());
993 return it->second.children;
998 if (!blockSinceLastRollingFeeBump || rollingMinimumFeeRate == 0)
999 return CFeeRate(rollingMinimumFeeRate);
1002 if (time > lastRollingFeeUpdate + 10) {
1003 double halflife = ROLLING_FEE_HALFLIFE;
1004 if (DynamicMemoryUsage() < sizelimit / 4)
1006 else if (DynamicMemoryUsage() < sizelimit / 2)
1009 rollingMinimumFeeRate = rollingMinimumFeeRate / pow(2.0, (time - lastRollingFeeUpdate) / halflife);
1010 lastRollingFeeUpdate = time;
1013 rollingMinimumFeeRate = 0;
1022 if (rate.
GetFeePerK() > rollingMinimumFeeRate) {
1024 blockSinceLastRollingFeeBump =
false;
1031 unsigned nTxnRemoved = 0;
1033 while (!mapTx.empty() && DynamicMemoryUsage() > sizelimit) {
1034 indexed_transaction_set::index<descendant_score>::type::iterator it = mapTx.get<
descendant_score>().begin();
1040 CFeeRate removed(it->GetModFeesWithDescendants(), it->GetSizeWithDescendants());
1042 trackPackageRemoved(removed);
1043 maxFeeRateRemoved =
std::max(maxFeeRateRemoved, removed);
1046 CalculateDescendants(mapTx.project<0>(it), stage);
1047 nTxnRemoved += stage.size();
1049 std::vector<CTransaction> txn;
1050 if (pvNoSpendsRemaining) {
1051 txn.reserve(stage.size());
1052 for (
txiter iter : stage)
1053 txn.push_back(iter->GetTx());
1056 if (pvNoSpendsRemaining) {
1058 for (
const CTxIn& txin : tx.vin) {
1060 if (!mapNextTx.count(txin.
prevout)) {
1061 pvNoSpendsRemaining->push_back(txin.
prevout);
1068 if (maxFeeRateRemoved >
CFeeRate(0)) {
1075 auto it = mapTx.find(txid);
1076 return it == mapTx.end() || (it->GetCountWithAncestors() < chainLimit &&
1077 it->GetCountWithDescendants() < chainLimit);
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost)
Compute the virtual transaction size (weight reinterpreted as bytes).
CAmount GetFeePerK() const
Return the fee in liu for a size of 1000 bytes.
CFeeRate GetMinFee(size_t sizelimit) const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
Information about a mempool transaction.
int Expire(int64_t time)
Expire all transaction (and their dependencies) in the mempool older than time.
void UpdateEntryForAncestors(txiter it, const setEntries &setAncestors)
Set ancestor state for an entry.
CAmount nModFeesWithDescendants
... and total fees (all including us)
void UpdateLockPoints(const LockPoints &lp)
void removeConflicts(const CTransaction &tx)
size_t nTxWeight
... and avoid recomputing tx weight (also used for GetTxSize())
bool CheckTxInputs(const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight)
Check whether all inputs of this transaction are valid (no double spends and amounts) This does not m...
CTxMemPoolEntry(const CTransactionRef &_tx, const CAmount &_nFee, int64_t _nTime, unsigned int _entryHeight, bool spendsCoinbase, int64_t nSigOpsCost, LockPoints lp, CAmount _nMinGasPrice=0)
int64_t GetTransactionWeight(const CTransaction &tx)
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason=MemPoolRemovalReason::UNKNOWN)
void trackPackageRemoved(const CFeeRate &rate)
boost::signals2::signal< void(CTransactionRef)> NotifyEntryAdded
uint256 GetWitnessHash() const
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
bool isSpent(const COutPoint &outpoint)
bool removeTx(uint256 hash, bool inBlock)
Remove a transaction from the mempool tracking stats.
reverse_range< T > reverse_iterate(T &x)
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...
const Consensus::Params & GetConsensus() const
bool HaveInputs(const CTransaction &tx) const
Check whether all prevouts of the transaction are present in the UTXO set represented by this view...
CTxMemPool(CBlockPolicyEstimator *estimator=nullptr)
Create a new CTxMemPool.
CTransactionRef get(const uint256 &hash) const
size_t DynamicMemoryUsage() const
std::set< txiter, CompareIteratorByHash > setEntries
void queryHashes(std::vector< uint256 > &vtxid)
std::hash for asio::adress
assert(len-trim+(2 *lenIndices)<=WIDTH)
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal...
size_t DynamicMemoryUsage() const
int64_t sigOpCost
Total sigop cost.
void TrimToSize(size_t sizelimit, std::vector< COutPoint > *pvNoSpendsRemaining=nullptr)
Remove transactions from the mempool until its dynamic size is <= sizelimit.
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
std::shared_ptr< const CTransaction > CTransactionRef
uint64_t nCountWithDescendants
number of descendant transactions
int64_t lastRollingFeeUpdate
CAmount nFee
Cached to avoid expensive parent-transaction lookups.
indirectmap< COutPoint, const CTransaction * > mapNextTx
const std::vector< CTxIn > vin
std::vector< TxMempoolInfo > infoAll() const
void UpdateTransactionsFromBlock(const std::vector< uint256 > &vHashesToUpdate)
When adding transactions from a disconnected block back to the mempool, new mempool entries may have ...
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...
virtual bool GetCoin(const COutPoint &outpoint, Coin &coin) const
Retrieve the Coin (unspent transaction output) for a given outpoint.
std::string ToString() const
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
unsigned int GetTransactionsUpdated() const
indexed_transaction_set mapTx
int64_t CAmount
Amount in lius (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 in size limiting.
int64_t nSigOpCostWithAncestors
std::vector< std::pair< uint256, txiter > > vTxHashes
All tx witness hashes/entries in mapTx, in random order.
void UpdateFeeDelta(int64_t feeDelta)
bool CheckFinalTx(const CTransaction &tx, int flags)
Check if transaction will be final in the next block to be created.
const_iterator cbegin() const
size_t nUsageSize
... and total memory usage
CTransactionRef GetSharedTx() const
int GetSpendHeight(const CCoinsViewCache &inputs)
Return the spend height, which is one more than the inputs.GetBestBlock().
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.
std::pair< iterator, bool > insert(const value_type &value)
An input of a transaction.
TxMempoolInfo info(const uint256 &hash) const
We want to be able to estimate feerates that are needed on tx's to be included in a certain number of...
iterator lower_bound(const K &key)
std::vector< indexed_transaction_set::const_iterator > GetSortedDepthAndScore() const
const setEntries & GetMemPoolParents(txiter entry) const
Removed for reorganization.
void UpdateParent(txiter entry, txiter parent, bool add)
std::map< uint256, CAmount > mapDeltas
void CalculateDescendants(txiter it, setEntries &setDescendants)
Populate setDescendants with all in-mempool descendants of hash.
const std::vector< CTxOut > vout
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or a pruned one if not found.
uint64_t cachedInnerUsage
sum of dynamic memory usage of all the map elements (NOT the maps themselves)
bool TestLockPointValidity(const LockPoints *lp)
Test whether the LockPoints height and time are still valid on the current chain. ...
const_iterator cend() const
CAmount nModFeesWithAncestors
unsigned int nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int modifySigOps)
Manually removed or unknown reason.
Parameters that influence chain consensus.
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)
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints *lp, bool useExistingLockPoints)
Check if transaction will be BIP 68 final in the next block to be created.
uint64_t totalTxSize
sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discount...
indexed_transaction_set::nth_index< 0 >::type::iterator txiter
bool exists(uint256 hash) const
void ApplyDelta(const uint256 hash, CAmount &nFeeDelta) const
std::string ToString() const
#define LogPrint(category,...)
CAmount GetFee(size_t nBytes) const
Return the fee in liu for the given size in bytes.
const setEntries & GetMemPoolChildren(txiter entry) const
Capture information about block/transaction validation.
virtual bool HaveCoin(const COutPoint &outpoint) const
Just check whether a given outpoint is unspent.
void UpdateChildrenForRemoval(txiter entry)
Sever link between specified transaction and direct children.
const CTransaction & GetTx() const
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void check(const CCoinsViewCache *pcoins) const
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
bool CompareDepthAndScore(const uint256 &hasha, const uint256 &hashb)
std::map< txiter, setEntries, CompareIteratorByHash > cacheMap
const CChainParams & Params()
Return the currently selected parameters.
LockPoints lockPoints
Track the height and time at which tx was final.
uint32_t nCheckFrequency
Value n means that n times in 2^32 we check.
void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount)
void UpdateForRemoveFromMempool(const setEntries &entriesToRemove, bool updateDescendants)
For each transaction being removed, update ancestors and any direct children.
uint64_t nCountWithAncestors
Fee rate in liu per kilobyte: CAmount / kB.
void UpdateChild(txiter entry, txiter child, bool add)
void ClearPrioritisation(const uint256 hash)
const uint256 & GetHash() const
void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors)
Update ancestors of hash to add/remove it as a descendant transaction.
boost::signals2::signal< void(CTransactionRef, MemPoolRemovalReason)> NotifyEntryRemoved
bool addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry, bool validFeeEstimate=true)
void removeForBlock(const std::vector< CTransactionRef > &vtx, unsigned int nBlockHeight)
Called when a block is connected.
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn)
dev::WithExisting max(dev::WithExisting _a, dev::WithExisting _b)
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
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 score of entry ((fee+delta)/size) in descending order.
void processBlock(unsigned int nBlockHeight, std::vector< const CTxMemPoolEntry * > &entries)
Process all the transactions that have been included in a block.
const CTxMemPool & mempool
CBlockPolicyEstimator * minerPolicyEstimator
double rollingMinimumFeeRate
minimum fee to get into the pool, decreases exponentially
CFeeRate incrementalRelayFee
iterator find(const K &key)
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags)
void removeUnchecked(txiter entry, MemPoolRemovalReason reason=MemPoolRemovalReason::UNKNOWN)
Before calling removeUnchecked for a given transaction, UpdateForRemoveFromMempool must be called on ...
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.
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
void RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason=MemPoolRemovalReason::UNKNOWN)
Remove a set of transactions from the mempool.
uint64_t GetRand(uint64_t nMax)
void processTransaction(const CTxMemPoolEntry &entry, bool validFeeEstimate)
Process a transaction accepted to the mempool.
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
void UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendants, const std::set< uint256 > &setExclude)
UpdateForDescendants is used by UpdateTransactionsFromBlock to update the descendants for a single tr...
size_type erase(const K &key)
size_type count(const K &key) const