34 bool unfinalizedOnly )
const {
35 while (!staged_ancestors.empty()) {
36 const auto stage = staged_ancestors.begin()->get();
38 txiter stageit = mapTx.find(stage->GetTx().GetId());
39 assert(stageit != mapTx.end());
40 setAncestors.insert(stageit);
41 staged_ancestors.erase(staged_ancestors.begin());
44 (*stageit)->GetMemPoolParentsConst();
45 for (
const auto &parent : parents) {
47 parent.get()->GetTx().GetId())) {
50 txiter parent_it = mapTx.find(parent.get()->GetTx().GetId());
51 assert(parent_it != mapTx.end());
54 if (setAncestors.count(parent_it) == 0) {
55 staged_ancestors.insert(parent);
63 bool unfinalizedOnly )
const {
67 if (unfinalizedOnly) {
68 for (
const auto &parent : entry->GetMemPoolParentsConst()) {
70 parent.get()->GetTx().GetId())) {
71 staged_ancestors.insert(parent);
75 staged_ancestors = entry->GetMemPoolParentsConst();
83 for (
const auto &parent : (*it)->GetMemPoolParentsConst()) {
84 auto parent_it = mapTx.find(parent.get()->GetTx().GetId());
85 assert(parent_it != mapTx.end());
92 (*it)->GetMemPoolChildrenConst();
93 for (
const auto &child : children) {
94 auto updateIt = mapTx.find(child.get()->GetTx().GetId());
95 assert(updateIt != mapTx.end());
101 for (
txiter removeIt : entriesToRemove) {
111 for (
txiter removeIt : entriesToRemove) {
117 : m_finalizedTxsFitter(
node::BlockFitter(config)),
120 m_opts{
std::move(opts)} {
129 return mapNextTx.count(outpoint);
142 entry->SetEntryId(nextEntryId++);
150 Assume(entry->GetFee() == entry->GetModifiedFee());
151 entry->UpdateModifiedFee(feeDelta);
156 auto [newit, inserted] = mapTx.insert(entry);
167 cachedInnerUsage += entry->DynamicMemoryUsage();
170 std::set<TxId> setParentTransactions;
171 for (
const CTxIn &in : tx->vin) {
172 mapNextTx.insert(std::make_pair(&in.prevout, tx));
173 setParentTransactions.insert(in.prevout.GetTxId());
180 for (
const auto &pit :
GetIterSet(setParentTransactions)) {
187 totalTxSize += entry->GetTxSize();
188 m_total_fee += entry->GetFee();
196 const TxId &txid = (*it)->GetTx().GetId();
205 (*it)->GetSharedTx(), reason, mempool_sequence);
209 m_finalizedTxsFitter.removeTxUnchecked(removed_tx->GetTxSize(),
210 removed_tx->GetSigChecks(),
211 removed_tx->GetFee());
215 for (
const CTxIn &txin : (*it)->GetTx().vin) {
216 mapNextTx.erase(txin.prevout);
222 totalTxSize -= (*it)->GetTxSize();
223 m_total_fee -= (*it)->GetFee();
224 cachedInnerUsage -= (*it)->DynamicMemoryUsage();
241 if (setDescendants.count(entryit) == 0) {
242 stage.insert(entryit);
247 while (!stage.empty()) {
248 txiter it = *stage.begin();
249 setDescendants.insert(it);
250 stage.erase(stage.begin());
253 (*it)->GetMemPoolChildrenConst();
254 for (
const auto &child : children) {
255 txiter childiter = mapTx.find(child.get()->GetTx().GetId());
256 assert(childiter != mapTx.end());
258 if (!setDescendants.count(childiter)) {
259 stage.insert(childiter);
270 txiter origit = mapTx.find(origTx.GetId());
271 if (origit != mapTx.end()) {
272 txToRemove.insert(origit);
278 auto it = mapNextTx.lower_bound(COutPoint(origTx.GetId(), 0));
279 while (it != mapNextTx.end() &&
280 it->first->GetTxId() == origTx.GetId()) {
281 txiter nextit = mapTx.find(it->second->GetId());
282 assert(nextit != mapTx.end());
283 txToRemove.insert(nextit);
289 for (
txiter it : txToRemove) {
299 for (
const CTxIn &txin : tx.vin) {
300 auto it = mapNextTx.find(txin.prevout);
301 if (it != mapNextTx.end()) {
302 const CTransaction &txConflict = *it->second;
303 if (txConflict != tx) {
319 lastRollingFeeUpdate =
GetTime();
320 blockSinceLastRollingFeeBump =
true;
324 const std::unordered_set<TxId, SaltedTxIdHasher>
325 &confirmedTxIdsInNonFinalizedBlocks) {
328 std::vector<CTxMemPoolEntryRef> finalizedTxsToKeep;
331 if (mapTx.count(entry->GetTx().GetId()) > 0 ||
332 confirmedTxIdsInNonFinalizedBlocks.count(
333 entry->GetTx().GetId()) > 0) {
337 finalizedTxsToKeep.push_back(entry);
349 m_finalizedTxsFitter.resetBlock();
350 for (
const auto &entry : finalizedTxsToKeep) {
354 m_finalizedTxsFitter.addTx(entry->GetTxSize(),
355 entry->GetSigChecks(), entry->GetFee());
367 cachedInnerUsage = 0;
368 lastRollingFeeUpdate =
GetTime();
369 blockSinceLastRollingFeeBump =
false;
370 rollingMinimumFeeRate = 0;
377 if (include_finalized_txs) {
380 m_finalizedTxsFitter.resetBlock();
385 int64_t spendheight)
const {
397 "Checking mempool with %u transactions and %u inputs\n",
398 (
unsigned int)mapTx.size(), (
unsigned int)mapNextTx.size());
400 uint64_t checkTotal = 0;
402 uint64_t innerUsage = 0;
408 checkTotal += entry->GetTxSize();
409 check_total_fee += entry->GetFee();
410 innerUsage += entry->DynamicMemoryUsage();
411 const CTransaction &tx = entry->GetTx();
416 for (
const CTxIn &txin : tx.vin) {
419 txiter parentIt = mapTx.find(txin.prevout.GetTxId());
420 if (parentIt != mapTx.end()) {
421 const CTransaction &parentTx = (*parentIt)->GetTx();
422 assert(parentTx.vout.size() > txin.prevout.GetN() &&
423 !parentTx.vout[txin.prevout.GetN()].IsNull());
424 setParentCheck.insert(*parentIt);
427 assert((*parentIt)->GetEntryId() < entry->GetEntryId());
433 assert(mempoolDuplicate.HaveCoin(txin.prevout));
435 auto prevoutNextIt = mapNextTx.find(txin.prevout);
436 assert(prevoutNextIt != mapNextTx.end());
437 assert(prevoutNextIt->first == &txin.prevout);
438 assert(prevoutNextIt->second.get() == &tx);
440 auto comp = [](
const auto &a,
const auto &b) ->
bool {
441 return a.get()->GetTx().GetId() == b.get()->GetTx().GetId();
443 assert(setParentCheck.size() == entry->GetMemPoolParentsConst().size());
444 assert(std::equal(setParentCheck.begin(), setParentCheck.end(),
445 entry->GetMemPoolParentsConst().begin(), comp));
452 for (
const auto &ancestor : setAncestors) {
453 assert((*ancestor)->GetEntryId() < entry->GetEntryId());
458 auto iter = mapNextTx.lower_bound(COutPoint(entry->GetTx().GetId(), 0));
459 for (; iter != mapNextTx.end() &&
460 iter->first->GetTxId() == entry->GetTx().GetId();
462 txiter childIt = mapTx.find(iter->second->GetId());
464 assert(childIt != mapTx.end());
465 setChildrenCheck.insert(*childIt);
467 assert(setChildrenCheck.size() ==
468 entry->GetMemPoolChildrenConst().size());
469 assert(std::equal(setChildrenCheck.begin(), setChildrenCheck.end(),
470 entry->GetMemPoolChildrenConst().begin(), comp));
477 spendheight, txfee));
478 for (
const auto &input : tx.vin) {
479 mempoolDuplicate.SpendCoin(input.prevout);
481 AddCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max());
484 for (
auto &[
_, nextTx] : mapNextTx) {
485 txiter it = mapTx.find(nextTx->GetId());
486 assert(it != mapTx.end());
487 assert((*it)->GetSharedTx() == nextTx);
490 assert(totalTxSize == checkTotal);
491 assert(m_total_fee == check_total_fee);
492 assert(innerUsage == cachedInnerUsage);
496 const TxId &txidb)
const {
498 auto it1 = mapTx.find(txida);
499 if (it1 == mapTx.end()) {
502 auto it2 = mapTx.find(txidb);
503 if (it2 == mapTx.end()) {
506 return (*it1)->GetEntryId() < (*it2)->GetEntryId();
513 vtxid.reserve(mapTx.size());
516 vtxid.push_back(entry->GetTx().GetId());
521GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
523 (*it)->GetFee(), (*it)->GetTxSize(),
524 (*it)->GetModifiedFee() - (*it)->GetFee()};
530 std::vector<TxMempoolInfo> ret;
531 ret.reserve(mapTx.size());
533 const auto &index = mapTx.get<
entry_id>();
534 for (
auto it = index.begin(); it != index.end(); ++it) {
535 ret.push_back(
GetInfo(mapTx.project<0>(it)));
545 std::vector<TxId> &finalizedTxIds) {
549 auto it = mapTx.find(tx->GetTx().GetId());
550 if (it == mapTx.end()) {
552 LogPrintf(
"Trying to finalize tx %s that is not in the mempool\n",
553 tx->GetTx().GetId().ToString());
558 finalizedTxIds.clear();
563 setAncestors.insert(it);
568 uint64_t sumOfTxSize{0};
569 uint64_t sumOfTxSigChecks{0};
570 for (
txiter ancestor_it : setAncestors) {
575 entry->GetTx(), state)) {
577 "Delay storing finalized tx %s that would cause the block "
578 "to be invalid%s (%s)\n",
579 tx->GetTx().GetId().ToString(),
580 entry->GetSharedTx()->GetId() == tx->GetSharedTx()->GetId()
583 entry->GetSharedTx()->GetId().ToString()),
588 if (m_finalizedTxsFitter.isBelowBlockMinFeeRate(
589 entry->GetModifiedFeeRate())) {
591 "Delay storing finalized tx %s due to fee rate below the "
592 "block mininmum%s (see -blockmintxfee)\n",
593 tx->GetTx().GetId().ToString(),
594 entry->GetSharedTx()->GetId() == tx->GetSharedTx()->GetId()
597 entry->GetSharedTx()->GetId().ToString()));
603 for (
const CTxIn &txin : entry->GetTx().vin) {
605 if (mapTx.count(txin.prevout.GetTxId()) != 0) {
622 "Delay storing finalized tx %s as it spends a "
623 "coin from a non-finalized block%s\n",
624 tx->GetTx().GetId().ToString(),
625 entry->GetSharedTx()->GetId() == tx->GetSharedTx()->GetId()
628 entry->GetSharedTx()->GetId().ToString()));
633 sumOfTxSize += entry->GetTxSize();
634 sumOfTxSigChecks += entry->GetSigChecks();
637 if (!m_finalizedTxsFitter.testTxFits(sumOfTxSize, sumOfTxSigChecks)) {
640 "Delay storing finalized tx %s as it won't fit in the next block\n",
641 tx->GetTx().GetId().ToString());
645 finalizedTxIds.clear();
649 for (
txiter ancestor_it : setAncestors) {
651 m_finalizedTxsFitter.addTx((*ancestor_it)->GetTxSize(),
652 (*ancestor_it)->GetSigChecks(),
653 (*ancestor_it)->GetFee());
655 finalizedTxIds.push_back((*ancestor_it)->GetTx().GetId());
659 (*ancestor_it)->GetSharedTx());
673 const TxId &txid = tx->GetId();
679 return !m_finalizedTxsFitter.isBelowBlockMinFeeRate(
680 entry->GetModifiedFeeRate()) &&
681 m_finalizedTxsFitter.testTxFits(entry->GetTxSize(),
682 entry->GetSigChecks());
690 return m_conflicting && m_conflicting->HaveTx(txid));
695 indexed_transaction_set::const_iterator i = mapTx.find(txid);
696 if (i == mapTx.end()) {
700 return (*i)->GetSharedTx();
705 indexed_transaction_set::const_iterator i = mapTx.find(txid);
706 if (i == mapTx.end()) {
727 Amount &delta = mapDeltas[txid];
729 txiter it = mapTx.find(txid);
730 if (it != mapTx.end()) {
732 e->UpdateModifiedFee(nFeeDelta);
743 std::map<TxId, Amount>::const_iterator pos = mapDeltas.find(txid);
744 if (pos == mapDeltas.end()) {
748 nFeeDelta += pos->second;
753 mapDeltas.erase(txid);
757 const auto it = mapNextTx.find(prevout);
758 return it == mapNextTx.end() ? nullptr : it->second;
762 auto it = mapTx.find(txid);
763 if (it != mapTx.end()) {
772 for (
const auto &txid : txids) {
782 for (
const CTxIn &in : tx.vin) {
783 if (
exists(in.prevout.GetTxId())) {
809 if (outpoint.GetN() < ptx->vout.size()) {
820 for (uint32_t n = 0; n < tx->vout.size(); ++n) {
836 12 *
sizeof(
void *)) *
845 if (m_unbroadcast_txids.erase(txid)) {
849 (unchecked ?
" before confirmation that txn was sent out" :
""));
860 for (
txiter it : stageRevTopo) {
867 indexed_transaction_set::index<entry_time>::type::iterator it =
870 size_t skippedFinalizedTxs{0};
871 while (it != mapTx.get<
entry_time>().end() && (*it)->GetTime() < time) {
874 ++skippedFinalizedTxs;
876 toremove.insert(mapTx.project<0>(it));
882 if (skippedFinalizedTxs > 0) {
884 skippedFinalizedTxs);
888 for (
txiter removeit : toremove) {
902 "Expired %i transactions from the memory pool\n", expired);
905 std::vector<COutPoint> vNoSpendsRemaining;
907 for (
const COutPoint &removed : vNoSpendsRemaining) {
915 if (add && (*entry)->GetMemPoolChildren().insert(*child).second) {
917 }
else if (!add && (*entry)->GetMemPoolChildren().erase(*child)) {
925 if (add && (*entry)->GetMemPoolParents().insert(*parent).second) {
927 }
else if (!add && (*entry)->GetMemPoolParents().erase(*parent)) {
934 if (!blockSinceLastRollingFeeBump || rollingMinimumFeeRate == 0) {
939 if (time > lastRollingFeeUpdate + 10) {
947 rollingMinimumFeeRate =
948 rollingMinimumFeeRate /
949 pow(2.0, (time - lastRollingFeeUpdate) / halflife);
950 lastRollingFeeUpdate = time;
959 blockSinceLastRollingFeeBump =
false;
964 std::vector<COutPoint> *pvNoSpendsRemaining) {
967 unsigned nTxnRemoved = 0;
968 size_t finalizedTxsSkipped = 0;
973 auto rit = by_modified_feerate.rbegin();
977 ++finalizedTxsSkipped;
979 if (rit == by_modified_feerate.rend()) {
991 if (rit == by_modified_feerate.rend()) {
994 auto it = rit.base();
1002 CFeeRate removed = (*it)->GetModifiedFeeRate();
1006 maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed);
1010 nTxnRemoved += stage.size();
1012 if (pvNoSpendsRemaining) {
1013 for (
const txiter &iter : stage) {
1014 for (
const CTxIn &txin : (*iter)->GetTx().vin) {
1015 if (!
exists(txin.prevout.GetTxId())) {
1016 pvNoSpendsRemaining->push_back(txin.prevout);
1027 "Removed %u txn, rolling minimum fee bumped to %s\n",
1028 nTxnRemoved, maxFeeRateRemoved.
ToString());
1031 if (finalizedTxsSkipped > 0) {
1033 "Not evicting %u finalized txn for low fee\n",
1034 finalizedTxsSkipped);
1040 return m_load_tried;
1045 m_load_tried = load_tried;
static constexpr Amount SATOSHI
#define Assume(val)
Assume is the identity function.
The block chain is a tree shaped structure starting with the genesis block at the root,...
CCoinsView backed by another CCoinsView.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
void Uncache(const COutPoint &outpoint)
Removes the UTXO with the given outpoint from the cache, if it is not modified.
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
Abstract view on the open txout dataset.
virtual std::optional< Coin > GetCoin(const COutPoint &outpoint) const
Retrieve the Coin (unspent transaction output) for a given outpoint.
std::optional< Coin > GetCoin(const COutPoint &outpoint) const override
GetCoin, returning whether it exists and is not spent.
void Reset()
Clear m_temp_added and m_non_base_coins.
std::unordered_map< COutPoint, Coin, SaltedOutpointHasher > m_temp_added
Coins made available by transactions being validated.
CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn)
std::unordered_set< COutPoint, SaltedOutpointHasher > m_non_base_coins
Set of all coins that have been fetched from mempool or created using PackageAddTransaction (not base...
void PackageAddTransaction(const CTransactionRef &tx)
Add the coins created by this transaction.
const CTxMemPool & mempool
Fee rate in satoshis per virtualbyte: Amount / vB the feerate is represented internally as FeeFrac.
std::string ToString() const
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
std::set< std::reference_wrapper< const CTxMemPoolEntryRef >, CompareIteratorById > Children
std::set< std::reference_wrapper< const CTxMemPoolEntryRef >, CompareIteratorById > Parents
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
CFeeRate estimateFee() const
bool HasNoInputsOf(const CTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Check that none of this transactions inputs are in the mempool, and thus the tx is not dependent on o...
void ClearPrioritisation(const TxId &txid) EXCLUSIVE_LOCKS_REQUIRED(cs)
std::set< txiter, CompareIteratorById > setEntries
void CalculateAncestors(setEntries &setAncestors, CTxMemPoolEntry::Parents &staged_ancestors, bool unfinalizedOnly=false) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Helper function to calculate all in-mempool ancestors of staged_ancestors.
void RemoveUnbroadcastTx(const TxId &txid, const bool unchecked=false)
Removes a transaction from the unbroadcast set.
bool GetLoadTried() const
void updateFeeForBlock() EXCLUSIVE_LOCKS_REQUIRED(cs)
Called when a block is connected.
CFeeRate GetMinFee() const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs)
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
void UpdateForRemoveFromMempool(const setEntries &entriesToRemove) EXCLUSIVE_LOCKS_REQUIRED(cs)
For each transaction being removed, update ancestors and any direct children.
void TrimToSize(size_t sizelimit, std::vector< COutPoint > *pvNoSpendsRemaining=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove transactions from the mempool until its dynamic size is <= sizelimit.
void AddTransactionsUpdated(unsigned int n)
void UpdateChildrenForRemoval(txiter entry) EXCLUSIVE_LOCKS_REQUIRED(cs)
Sever link between specified transaction and direct children.
bool setAvalancheFinalized(const CTxMemPoolEntryRef &tx, const Consensus::Params ¶ms, const CBlockIndex &active_chain_tip, Chainstate &active_chainstate, std::vector< TxId > &finalizedTxIds) EXCLUSIVE_LOCKS_REQUIRED(bool isAvalancheFinalizedPreConsensus(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
bool CompareTopologically(const TxId &txida, const TxId &txidb) const
TxMempoolInfo info(const TxId &txid) const
void getAllTxIds(std::vector< TxId > &vtxid) const
std::atomic< uint32_t > nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
setEntries GetIterSet(const std::set< TxId > &txids) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Translate a set of txids into a set of pool iterators to avoid repeated lookups.
size_t DynamicMemoryUsage() const
std::vector< TxMempoolInfo > infoAll() const
void LimitSize(CCoinsViewCache &coins_cache) EXCLUSIVE_LOCKS_REQUIRED(cs
Reduce the size of the mempool by expiring and then trimming the mempool.
void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
CTransactionRef GetConflictTx(const COutPoint &prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Get the transaction in the pool that spends the same prevout.
void removeUnchecked(txiter entry, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Before calling removeUnchecked for a given transaction, UpdateForRemoveFromMempool must be called on ...
int Expire(std::chrono::seconds time) EXCLUSIVE_LOCKS_REQUIRED(cs)
Expire all transaction (and their dependencies) in the mempool older than time.
bool isWorthPolling(const CTransactionRef &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs
std::set< txiter, CompareIteratorByRevEntryId > setRevTopoEntries
bool exists(const TxId &txid) const
static const int ROLLING_FEE_HALFLIFE
CTransactionRef get(const TxId &txid) const
void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
CTxMemPool(const Config &config, Options opts)
Create a new CTxMemPool.
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
uint64_t GetAndIncrementSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
Guards this internal counter for external reporting.
void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void addUnchecked(CTxMemPoolEntryRef entry) EXCLUSIVE_LOCKS_REQUIRED(cs
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
RadixTree< CTxMemPoolEntry, MemPoolEntryRadixTreeAdapter > finalizedTxs
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void cs_main
void CalculateMemPoolAncestors(const CTxMemPoolEntryRef &entry, setEntries &setAncestors, bool unfinalizedOnly=false) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Calculate all in-mempool ancestors of entry.
void removeForFinalizedBlock(const std::unordered_set< TxId, SaltedTxIdHasher > &confirmedTxIdsInNonFinalizedBlocks) EXCLUSIVE_LOCKS_REQUIRED(cs)
void clear(bool include_finalized_txs=false)
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of hash.
void RemoveStaged(const setEntries &stage, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove a set of transactions from the mempool.
void UpdateParentsOf(bool add, txiter it) EXCLUSIVE_LOCKS_REQUIRED(cs)
Update parents of it to add/remove it as a child transaction.
void ApplyDelta(const TxId &txid, Amount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs)
void SetLoadTried(bool load_tried)
Set whether or not an initial attempt to load the persisted mempool was made (regardless of whether t...
std::optional< txiter > GetIter(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given txid, if found.
bool isSpent(const COutPoint &outpoint) const
unsigned int GetTransactionsUpdated() const
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs)
Chainstate stores and provides an API to update our local knowledge of the current best chain.
bool IsBlockAvalancheFinalized(const CBlockIndex *pindex) const EXCLUSIVE_LOCKS_REQUIRED(!cs_avalancheFinalizedBlockIndex)
Checks if a block is finalized by avalanche voting.
CChain m_chain
The current chain of blockheaders we consult and build on.
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
uint32_t GetHeight() const
T * get()
Get allows to access the undelying pointer.
void TransactionFinalized(const CTransactionRef &tx)
void TransactionRemovedFromMempool(const CTransactionRef &, MemPoolRemovalReason, uint64_t mempool_sequence)
std::string ToString() const
std::string ToString() const
std::string GetHex() const
void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, bool check_for_overwrite)
Utility function to add all of a transaction's outputs to a cache.
#define LogDebug(category,...)
std::string FormatMoney(const Amount amt)
Do not use these functions to represent or parse monetary amounts to or from JSON but use AmountFromV...
bool CheckTxInputs(const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight, Amount &txfee)
Check whether all inputs of this transaction are valid (no double spends and amounts).
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
static size_t IncrementalDynamicUsage(const std::set< X, Y > &s)
static size_t MallocUsage(size_t alloc)
Compute the total memory used by allocating alloc bytes.
Implement std::hash so RCUPtr can be used as a key for maps or sets.
static const CFeeRate MEMPOOL_FULL_FEE_INCREMENT(1000 *SATOSHI)
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP...
std::shared_ptr< const CTransaction > CTransactionRef
void SaturatingAdd(const Amount &other) noexcept
Amount addition with integer saturation.
static constexpr Amount zero() noexcept
Parameters that influence chain consensus.
RCUPtr< T > remove(const KeyType &key)
Remove an element from the tree.
bool forEachLeaf(Callable &&func) const
bool insert(const RCUPtr< T > &value)
Insert a value into the tree.
A TxId is the identifier of a transaction.
Information about a mempool transaction.
Options struct containing options for constructing a CTxMemPool.
int check_ratio
The ratio used to determine how often sanity checks will run.
ValidationSignals * signals
CFeeRate min_relay_feerate
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)
std::chrono::seconds expiry
#define AssertLockNotHeld(cs)
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
#define NO_THREAD_SAFETY_ANALYSIS
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
bilingual_str _(const char *psz)
Translation function.
bool ContextualCheckTransactionForCurrentBlock(const CBlockIndex &active_chain_tip, const Consensus::Params ¶ms, const CTransaction &tx, TxValidationState &state)
std::string RemovalReasonToString(const MemPoolRemovalReason &r) noexcept
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it)
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
@ SIZELIMIT
Removed in size limiting.
@ BLOCK
Removed for block.
@ MANUAL
Manual removal via RPC.
@ EXPIRY
Expired from mempool.
@ AVALANCHE
Removed by avalanche vote.
@ CONFLICT
Removed for conflict with in-block transaction.
@ REORG
Removed for reorganization.
static const uint32_t MEMPOOL_HEIGHT
Fake height value used in Coins to signify they are only in the memory pool(since 0....