Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
CTxMemPool Class Reference

CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the next block. More...

#include <txmempool.h>

Collaboration diagram for CTxMemPool:
[legend]

Public Types

typedef boost::multi_index_container< CTxMemPoolEntryRef, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< mempoolentry_txid, SaltedTxIdHasher >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< modified_feerate >, boost::multi_index::identity< CTxMemPoolEntryRef >, CompareTxMemPoolEntryByModifiedFeeRate >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< entry_time >, boost::multi_index::identity< CTxMemPoolEntryRef >, CompareTxMemPoolEntryByEntryTime >, boost::multi_index::ordered_unique< boost::multi_index::tag< entry_id >, boost::multi_index::identity< CTxMemPoolEntryRef >, CompareTxMemPoolEntryByEntryId > > > indexed_transaction_set
 
using txiter = indexed_transaction_set::nth_index< 0 >::type::const_iterator
 
typedef std::set< txiter, CompareIteratorByIdsetEntries
 
typedef std::set< txiter, CompareIteratorByRevEntryIdsetRevTopoEntries
 
using Options = kernel::MemPoolOptions
 

Public Member Functions

indexed_transaction_set mapTx GUARDED_BY (cs)
 
indirectmap< COutPoint, CTransactionRef > mapNextTx GUARDED_BY (cs)
 
std::map< TxId, Amount > mapDeltas GUARDED_BY (cs)
 
 CTxMemPool (const Options &opts)
 Create a new CTxMemPool.
 
 ~CTxMemPool ()
 
void removeRecursive (const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
 
void removeConflicts (const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
 
void updateFeeForBlock () EXCLUSIVE_LOCKS_REQUIRED(cs)
 Called when a block is connected.
 
void removeForFinalizedBlock (const std::vector< CTransactionRef > &vtx) EXCLUSIVE_LOCKS_REQUIRED(cs)
 
void clear ()
 
void _clear () EXCLUSIVE_LOCKS_REQUIRED(cs)
 
bool CompareTopologically (const TxId &txida, const TxId &txidb) const
 
void getAllTxIds (std::vector< TxId > &vtxid) const
 
bool isSpent (const COutPoint &outpoint) const
 
unsigned int GetTransactionsUpdated () const
 
void AddTransactionsUpdated (unsigned int n)
 
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 other mempool transactions to be included in a block.
 
void PrioritiseTransaction (const TxId &txid, const Amount nFeeDelta)
 Affect CreateNewBlock prioritisation of transactions.
 
void ApplyDelta (const TxId &txid, Amount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs)
 
void ClearPrioritisation (const TxId &txid) 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.
 
std::optional< txiterGetIter (const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
 Returns an iterator to the given txid, if found.
 
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.
 
void RemoveStaged (const setEntries &stage, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
 Remove a set of transactions from the mempool.
 
bool CalculateMemPoolAncestors (const CTxMemPoolEntryRef &entry, setEntries &setAncestors, bool fSearchForParents=true) const EXCLUSIVE_LOCKS_REQUIRED(cs)
 Try to calculate all in-mempool ancestors of entry.
 
void CalculateDescendants (txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
 Populate setDescendants with all in-mempool descendants of hash.
 
CFeeRate GetMinFee () const
 The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions.
 
CFeeRate GetMinFee (size_t sizelimit) const
 
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.
 
int Expire (std::chrono::seconds time) EXCLUSIVE_LOCKS_REQUIRED(cs)
 Expire all transaction (and their dependencies) in the mempool older than time.
 
void LimitSize (CCoinsViewCache &coins_cache) EXCLUSIVE_LOCKS_REQUIRED(cs
 Reduce the size of the mempool by expiring and then trimming the mempool.
 
bool GetLoadTried () const
 
void SetLoadTried (bool load_tried)
 Set whether or not we've made an attempt to load the mempool (regardless of whether the attempt was successful or not)
 
unsigned long size () const
 
uint64_t GetTotalTxSize () const EXCLUSIVE_LOCKS_REQUIRED(cs)
 
Amount GetTotalFee () const EXCLUSIVE_LOCKS_REQUIRED(cs)
 
bool exists (const TxId &txid) const
 
bool setAvalancheFinalized (const CTxMemPoolEntryRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs)
 
bool isAvalancheFinalized (const TxId &txid) const
 
CTransactionRef get (const TxId &txid) const
 
TxMempoolInfo info (const TxId &txid) const
 
std::vector< TxMempoolInfoinfoAll () const
 
CFeeRate estimateFee () const
 
size_t DynamicMemoryUsage () const
 
void AddUnbroadcastTx (const TxId &txid)
 Adds a transaction to the unbroadcast set.
 
void RemoveUnbroadcastTx (const TxId &txid, const bool unchecked=false)
 Removes a transaction from the unbroadcast set.
 
std::set< TxIdGetUnbroadcastTxs () const
 Returns transactions in unbroadcast set.
 
bool IsUnbroadcastTx (const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
 Returns whether a txid is in the unbroadcast set.
 
uint64_t GetAndIncrementSequence () const EXCLUSIVE_LOCKS_REQUIRED(cs)
 Guards this internal counter for external reporting.
 
uint64_t GetSequence () const EXCLUSIVE_LOCKS_REQUIRED(cs)
 
template<typename Callable >
auto withOrphanage (Callable &&func) const EXCLUSIVE_LOCKS_REQUIRED(!cs_orphanage)
 
template<typename Callable >
auto withConflicting (Callable &&func) const EXCLUSIVE_LOCKS_REQUIRED(!cs_conflicting)
 

Public Attributes

RecursiveMutex cs
 This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
 
RadixTree< CTxMemPoolEntry, MemPoolEntryRadixTreeAdapterfinalizedTxs
 
const int64_t m_max_size_bytes
 
const std::chrono::seconds m_expiry
 
const CFeeRate m_min_relay_feerate
 
const CFeeRate m_dust_relay_feerate
 
const bool m_permit_bare_multisig
 
const std::optional< unsignedm_max_datacarrier_bytes
 
const bool m_require_standard
 
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 transactions that spend the same inputs, all inputs are in the mapNextTx array).
 
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void cs_main
 

Static Public Attributes

static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12
 

Private Member Functions

uint64_t totalTxSize GUARDED_BY (cs)
 sum of all mempool tx's sizes.
 
Amount m_total_fee GUARDED_BY (cs)
 sum of all mempool tx's fees (NOT modified fee)
 
uint64_t cachedInnerUsage GUARDED_BY (cs)
 sum of dynamic memory usage of all the map elements (NOT the maps themselves)
 
int64_t lastRollingFeeUpdate GUARDED_BY (cs)
 
bool blockSinceLastRollingFeeBump GUARDED_BY (cs)
 
double rollingMinimumFeeRate GUARDED_BY (cs)
 minimum fee to get into the pool, decreases exponentially
 
uint64_t m_sequence_number GUARDED_BY (cs)
 
void trackPackageRemoved (const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs)
 
bool m_load_tried GUARDED_BY (cs)
 
uint64_t nextEntryId GUARDED_BY (cs)
 Used by addUnchecked to generate ever-increasing CTxMemPoolEntry::entryId's.
 
std::unique_ptr< TxOrphanage > m_orphanage GUARDED_BY (cs_orphanage)
 Storage for orphan information.
 
std::unique_ptr< TxConflicting > m_conflicting GUARDED_BY (cs_conflicting)
 Storage for conflicting txs information.
 
void UpdateParent (txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
 
void UpdateChild (txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs)
 
std::set< TxId > m_unbroadcast_txids GUARDED_BY (cs)
 Track locally submitted transactions to periodically retry initial broadcast.
 
bool CalculateAncestors (setEntries &setAncestors, CTxMemPoolEntry::Parents &staged_ancestors) const EXCLUSIVE_LOCKS_REQUIRED(cs)
 Helper function to calculate all in-mempool ancestors of staged_ancestors param@[in] staged_ancestors Should contain entries in the mempool.
 
void UpdateEntryForAncestors (txiter it, const setEntries *setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs)
 Set ancestor state for an entry.
 
void UpdateParentsOf (bool add, txiter it) EXCLUSIVE_LOCKS_REQUIRED(cs)
 Update parents of it to add/remove it as a child transaction.
 
void UpdateForRemoveFromMempool (const setEntries &entriesToRemove) EXCLUSIVE_LOCKS_REQUIRED(cs)
 For each transaction being removed, update ancestors and any direct children.
 
void UpdateChildrenForRemoval (txiter entry) EXCLUSIVE_LOCKS_REQUIRED(cs)
 Sever link between specified transaction and direct children.
 
void removeUnchecked (txiter entry, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
 Before calling removeUnchecked for a given transaction, UpdateForRemoveFromMempool must be called on the entire (dependent) set of transactions being removed at the same time.
 

Private Attributes

const int m_check_ratio
 Value n means that 1 times in n we check.
 
std::atomic< uint32_tnTransactionsUpdated {0}
 Used by getblocktemplate to trigger CreateNewBlock() invocation.
 
Mutex cs_orphanage
 
Mutex cs_conflicting
 

Detailed Description

CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the next block.

Transactions are added when they are seen on the network (or created by the local node), but not all transactions seen are added to the pool. For example, the following new transactions will not be added to the mempool:

CTxMemPool::mapTx, and CTxMemPoolEntry bookkeeping:

mapTx is a boost::multi_index that sorts the mempool on 3 criteria:

Note: the term "descendant" refers to in-mempool transactions that depend on this one, while "ancestor" refers to in-mempool transactions that a given transaction depends on.

When a new transaction is added to the mempool, it has no in-mempool children (because any such children would be an orphan). So in addUnchecked(), we:

When a transaction is removed from the mempool, we must:

These happen in UpdateForRemoveFromMempool(). (Note that when removing a transaction along with its descendants, we must calculate that set of transactions to be removed before doing the removal, or else the mempool can be in an inconsistent state where it's impossible to walk the ancestors of a transaction.)

In the event of a reorg, the invariant that all newly-added tx's have no in-mempool children must be maintained. On top of this, we use a topological index (GetEntryId). As such, we always dump mempool tx's into a disconnect pool on reorg, and simply add them one by one, along with tx's from disconnected blocks, when the reorg is complete.

Definition at line 212 of file txmempool.h.

Member Typedef Documentation

◆ indexed_transaction_set

typedef boost::multi_index_container< CTxMemPoolEntryRef, boost::multi_index::indexed_by< boost::multi_index::hashed_unique<mempoolentry_txid, SaltedTxIdHasher>, boost::multi_index::ordered_non_unique< boost::multi_index::tag<modified_feerate>, boost::multi_index::identity<CTxMemPoolEntryRef>, CompareTxMemPoolEntryByModifiedFeeRate>, boost::multi_index::ordered_non_unique< boost::multi_index::tag<entry_time>, boost::multi_index::identity<CTxMemPoolEntryRef>, CompareTxMemPoolEntryByEntryTime>, boost::multi_index::ordered_unique< boost::multi_index::tag<entry_id>, boost::multi_index::identity<CTxMemPoolEntryRef>, CompareTxMemPoolEntryByEntryId> > > CTxMemPool::indexed_transaction_set

Definition at line 278 of file txmempool.h.

◆ Options

Definition at line 342 of file txmempool.h.

◆ setEntries

Definition at line 311 of file txmempool.h.

◆ setRevTopoEntries

Definition at line 312 of file txmempool.h.

◆ txiter

using CTxMemPool::txiter = indexed_transaction_set::nth_index<0>::type::const_iterator

Definition at line 310 of file txmempool.h.

Constructor & Destructor Documentation

◆ CTxMemPool()

CTxMemPool::CTxMemPool ( const Options opts)

Create a new CTxMemPool.

Sanity checks will be off by default for performance, because otherwise accepting transactions becomes O(N^2) where N is the number of transactions in the pool.

Definition at line 117 of file txmempool.cpp.

Here is the call graph for this function:

◆ ~CTxMemPool()

CTxMemPool::~CTxMemPool ( )

Definition at line 131 of file txmempool.cpp.

Member Function Documentation

◆ _clear()

void CTxMemPool::_clear ( )

Definition at line 331 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddTransactionsUpdated()

void CTxMemPool::AddTransactionsUpdated ( unsigned int  n)

Definition at line 142 of file txmempool.cpp.

◆ AddUnbroadcastTx()

void CTxMemPool::AddUnbroadcastTx ( const TxId txid)
inline

Adds a transaction to the unbroadcast set.

Definition at line 527 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ApplyDelta()

void CTxMemPool::ApplyDelta ( const TxId txid,
Amount nFeeDelta 
) const

Definition at line 556 of file txmempool.cpp.

Here is the call graph for this function:

◆ CalculateAncestors()

bool CTxMemPool::CalculateAncestors ( setEntries setAncestors,
CTxMemPoolEntry::Parents staged_ancestors 
) const
private

Helper function to calculate all in-mempool ancestors of staged_ancestors param@[in] staged_ancestors Should contain entries in the mempool.

param@[out] setAncestors Will be populated with all mempool ancestors.

Definition at line 29 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculateDescendants()

void CTxMemPool::CalculateDescendants ( txiter  it,
setEntries setDescendants 
) const

Populate setDescendants with all in-mempool descendants of hash.

Assumes that setDescendants includes all in-mempool descendants of anything already in it.

Definition at line 235 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculateMemPoolAncestors()

bool CTxMemPool::CalculateMemPoolAncestors ( const CTxMemPoolEntryRef entry,
setEntries setAncestors,
bool  fSearchForParents = true 
) const

Try to calculate all in-mempool ancestors of entry.

(these are all calculated including the tx itself) fSearchForParents = whether to search a tx's vin for in-mempool parents, or look up parents from m_parents. Must be true for entries not in the mempool

Definition at line 56 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void CTxMemPool::clear ( )

Definition at line 343 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearPrioritisation()

void CTxMemPool::ClearPrioritisation ( const TxId txid)

Definition at line 566 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompareTopologically()

bool CTxMemPool::CompareTopologically ( const TxId txida,
const TxId txidb 
) const

Definition at line 462 of file txmempool.cpp.

Here is the call graph for this function:

◆ DynamicMemoryUsage()

size_t CTxMemPool::DynamicMemoryUsage ( ) const

Definition at line 646 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ estimateFee()

CFeeRate CTxMemPool::estimateFee ( ) const

Definition at line 528 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exists()

bool CTxMemPool::exists ( const TxId txid) const
inline

Definition at line 503 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Expire()

int CTxMemPool::Expire ( std::chrono::seconds  time)

Expire all transaction (and their dependencies) in the mempool older than time.

Return the number of removed transactions.

Definition at line 680 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

CTransactionRef CTxMemPool::get ( const TxId txid) const

Definition at line 508 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAllTxIds()

void CTxMemPool::getAllTxIds ( std::vector< TxId > &  vtxid) const

Definition at line 476 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAndIncrementSequence()

uint64_t CTxMemPool::GetAndIncrementSequence ( ) const
inline

Guards this internal counter for external reporting.

Definition at line 552 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetConflictTx()

CTransactionRef CTxMemPool::GetConflictTx ( const COutPoint prevout) const

Get the transaction in the pool that spends the same prevout.

Definition at line 571 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetIter()

std::optional< CTxMemPool::txiter > CTxMemPool::GetIter ( const TxId txid) const

Returns an iterator to the given txid, if found.

Definition at line 576 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetIterSet()

CTxMemPool::setEntries CTxMemPool::GetIterSet ( const std::set< TxId > &  txids) const

Translate a set of txids into a set of pool iterators to avoid repeated lookups.

Definition at line 585 of file txmempool.cpp.

Here is the call graph for this function:

◆ GetLoadTried()

bool CTxMemPool::GetLoadTried ( ) const
Returns
true if we've made an attempt to load the mempool regardless of whether the attempt was successful or not

Definition at line 811 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMinFee() [1/2]

CFeeRate CTxMemPool::GetMinFee ( ) const
inline

The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions.

Definition at line 451 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMinFee() [2/2]

CFeeRate CTxMemPool::GetMinFee ( size_t  sizelimit) const

Definition at line 735 of file txmempool.cpp.

Here is the call graph for this function:

◆ GetSequence()

uint64_t CTxMemPool::GetSequence ( ) const
inline

Definition at line 556 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTotalFee()

Amount CTxMemPool::GetTotalFee ( ) const
inline

Definition at line 498 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTotalTxSize()

uint64_t CTxMemPool::GetTotalTxSize ( ) const
inline

Definition at line 493 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTransactionsUpdated()

unsigned int CTxMemPool::GetTransactionsUpdated ( ) const

Definition at line 138 of file txmempool.cpp.

Here is the caller graph for this function:

◆ GetUnbroadcastTxs()

std::set< TxId > CTxMemPool::GetUnbroadcastTxs ( ) const
inline

Returns transactions in unbroadcast set.

Definition at line 540 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GUARDED_BY() [1/15]

uint64_t totalTxSize CTxMemPool::GUARDED_BY ( cs  )
private

sum of all mempool tx's sizes.

◆ GUARDED_BY() [2/15]

Amount m_total_fee CTxMemPool::GUARDED_BY ( cs  )
private

sum of all mempool tx's fees (NOT modified fee)

◆ GUARDED_BY() [3/15]

uint64_t cachedInnerUsage CTxMemPool::GUARDED_BY ( cs  )
private

sum of dynamic memory usage of all the map elements (NOT the maps themselves)

◆ GUARDED_BY() [4/15]

int64_t lastRollingFeeUpdate CTxMemPool::GUARDED_BY ( cs  )
mutableprivate

◆ GUARDED_BY() [5/15]

bool blockSinceLastRollingFeeBump CTxMemPool::GUARDED_BY ( cs  )
mutableprivate

◆ GUARDED_BY() [6/15]

double rollingMinimumFeeRate CTxMemPool::GUARDED_BY ( cs  )
mutableprivate

minimum fee to get into the pool, decreases exponentially

◆ GUARDED_BY() [7/15]

uint64_t m_sequence_number CTxMemPool::GUARDED_BY ( cs  )
inlinemutableprivate

Definition at line 235 of file txmempool.h.

◆ GUARDED_BY() [8/15]

bool m_load_tried CTxMemPool::GUARDED_BY ( cs  )
inlineprivate

Definition at line 239 of file txmempool.h.

◆ GUARDED_BY() [9/15]

uint64_t nextEntryId CTxMemPool::GUARDED_BY ( cs  )
private

Used by addUnchecked to generate ever-increasing CTxMemPoolEntry::entryId's.

◆ GUARDED_BY() [10/15]

indexed_transaction_set mapTx CTxMemPool::GUARDED_BY ( cs  )

◆ GUARDED_BY() [11/15]

std::set< TxId > m_unbroadcast_txids CTxMemPool::GUARDED_BY ( cs  )
private

Track locally submitted transactions to periodically retry initial broadcast.

◆ GUARDED_BY() [12/15]

indirectmap< COutPoint, CTransactionRef > mapNextTx CTxMemPool::GUARDED_BY ( cs  )

◆ GUARDED_BY() [13/15]

std::map< TxId, Amount > mapDeltas CTxMemPool::GUARDED_BY ( cs  )

◆ GUARDED_BY() [14/15]

std::unique_ptr< TxConflicting > m_conflicting CTxMemPool::GUARDED_BY ( cs_conflicting  )
private

Storage for conflicting txs information.

◆ GUARDED_BY() [15/15]

std::unique_ptr< TxOrphanage > m_orphanage CTxMemPool::GUARDED_BY ( cs_orphanage  )
private

Storage for orphan information.

◆ HasNoInputsOf()

bool CTxMemPool::HasNoInputsOf ( const CTransaction tx) const

Check that none of this transactions inputs are in the mempool, and thus the tx is not dependent on other mempool transactions to be included in a block.

Definition at line 596 of file txmempool.cpp.

Here is the call graph for this function:

◆ info()

TxMempoolInfo CTxMemPool::info ( const TxId txid) const

Definition at line 518 of file txmempool.cpp.

Here is the call graph for this function:

◆ infoAll()

std::vector< TxMempoolInfo > CTxMemPool::infoAll ( ) const

Definition at line 494 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAvalancheFinalized()

bool CTxMemPool::isAvalancheFinalized ( const TxId txid) const
inline

Definition at line 513 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSpent()

bool CTxMemPool::isSpent ( const COutPoint outpoint) const

Definition at line 133 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsUnbroadcastTx()

bool CTxMemPool::IsUnbroadcastTx ( const TxId txid) const
inline

Returns whether a txid is in the unbroadcast set.

Definition at line 546 of file txmempool.h.

Here is the call graph for this function:

◆ LimitSize()

void CTxMemPool::LimitSize ( CCoinsViewCache coins_cache)

Reduce the size of the mempool by expiring and then trimming the mempool.

Definition at line 699 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrioritiseTransaction()

void CTxMemPool::PrioritiseTransaction ( const TxId txid,
const Amount  nFeeDelta 
)

Affect CreateNewBlock prioritisation of transactions.

Definition at line 538 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeConflicts()

void CTxMemPool::removeConflicts ( const CTransaction tx)

Definition at line 293 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeForFinalizedBlock()

void CTxMemPool::removeForFinalizedBlock ( const std::vector< CTransactionRef > &  vtx)

Definition at line 318 of file txmempool.cpp.

Here is the call graph for this function:

◆ removeRecursive()

void CTxMemPool::removeRecursive ( const CTransaction tx,
MemPoolRemovalReason  reason 
)

Definition at line 262 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveStaged()

void CTxMemPool::RemoveStaged ( const setEntries stage,
MemPoolRemovalReason  reason 
)

Remove a set of transactions from the mempool.

If a transaction is in this set, then all in-mempool descendants must also be in the set, unless this transaction is being removed for being in a block.

Definition at line 668 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveUnbroadcastTx()

void CTxMemPool::RemoveUnbroadcastTx ( const TxId txid,
const bool  unchecked = false 
)

Removes a transaction from the unbroadcast set.

Definition at line 657 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeUnchecked()

void CTxMemPool::removeUnchecked ( txiter  entry,
MemPoolRemovalReason  reason 
)
private

Before calling removeUnchecked for a given transaction, UpdateForRemoveFromMempool must be called on the entire (dependent) set of transactions being removed at the same time.

We use each CTxMemPoolEntry's setMemPoolParents in order to walk ancestors of a given transaction that is removed, so we can't remove intermediate transactions in a chain before we've updated all the state for the removal.

Definition at line 194 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAvalancheFinalized()

bool CTxMemPool::setAvalancheFinalized ( const CTxMemPoolEntryRef tx)
inline

Definition at line 508 of file txmempool.h.

Here is the call graph for this function:

◆ SetLoadTried()

void CTxMemPool::SetLoadTried ( bool  load_tried)

Set whether or not we've made an attempt to load the mempool (regardless of whether the attempt was successful or not)

Definition at line 816 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

unsigned long CTxMemPool::size ( ) const
inline

Definition at line 488 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ trackPackageRemoved()

void CTxMemPool::trackPackageRemoved ( const CFeeRate rate)
private

Definition at line 758 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TrimToSize()

void CTxMemPool::TrimToSize ( size_t  sizelimit,
std::vector< COutPoint > *  pvNoSpendsRemaining = nullptr 
)

Remove transactions from the mempool until its dynamic size is <= sizelimit.

pvNoSpendsRemaining, if set, will be populated with the list of outpoints which are not in mempool which no longer have any spends in this mempool.

Definition at line 766 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateChild()

void CTxMemPool::UpdateChild ( txiter  entry,
txiter  child,
bool  add 
)
private

Definition at line 715 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateChildrenForRemoval()

void CTxMemPool::UpdateChildrenForRemoval ( txiter  entry)
private

Sever link between specified transaction and direct children.

Definition at line 91 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateEntryForAncestors()

void CTxMemPool::UpdateEntryForAncestors ( txiter  it,
const setEntries setAncestors 
)
private

Set ancestor state for an entry.

◆ updateFeeForBlock()

void CTxMemPool::updateFeeForBlock ( )

Called when a block is connected.

Updates the miner fee estimator.

Definition at line 311 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateForRemoveFromMempool()

void CTxMemPool::UpdateForRemoveFromMempool ( const setEntries entriesToRemove)
private

For each transaction being removed, update ancestors and any direct children.

Definition at line 101 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateParent()

void CTxMemPool::UpdateParent ( txiter  entry,
txiter  parent,
bool  add 
)
private

Definition at line 725 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateParentsOf()

void CTxMemPool::UpdateParentsOf ( bool  add,
txiter  it 
)
private

Update parents of it to add/remove it as a child transaction.

Definition at line 82 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withConflicting()

template<typename Callable >
auto CTxMemPool::withConflicting ( Callable &&  func) const
inline

Definition at line 569 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withOrphanage()

template<typename Callable >
auto CTxMemPool::withOrphanage ( Callable &&  func) const
inline

Definition at line 561 of file txmempool.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ addUnchecked

void CTxMemPool::addUnchecked

If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transactions that spend the same inputs, all inputs are in the mapNextTx array).

If sanity-checking is turned off, check does nothing.

Definition at line 372 of file txmempool.h.

◆ cs

RecursiveMutex CTxMemPool::cs
mutable

This mutex needs to be locked when accessing mapTx or other members that are guarded by it.

Consistency guarantees

By design, it is guaranteed that:

  1. Locking both cs_main and mempool.cs will give a view of mempool that is consistent with current chain tip (ActiveChain() and CoinsTip()) and is fully populated. Fully populated means that if the current active chain is missing transactions that were present in a previously active chain, all the missing transactions will have been re-added to the mempool and should be present if they meet size and consistency constraints.
  2. Locking mempool.cs without cs_main will give a view of a mempool consistent with some chain that was active since cs_main was last locked, and that is fully populated as described above. It is ok for code that only needs to query or remove transactions from the mempool to lock just mempool.cs without cs_main.

To provide these guarantees, it is necessary to lock both cs_main and mempool.cs whenever adding transactions to the mempool and whenever changing the chain tip. It's necessary to keep both mutexes locked until the mempool is consistent with the new chain tip and fully populated.

Definition at line 307 of file txmempool.h.

◆ cs_conflicting

Mutex CTxMemPool::cs_conflicting
mutableprivate

Definition at line 249 of file txmempool.h.

◆ cs_main

Definition at line 373 of file txmempool.h.

◆ cs_orphanage

Mutex CTxMemPool::cs_orphanage
mutableprivate

Definition at line 245 of file txmempool.h.

◆ finalizedTxs

Definition at line 314 of file txmempool.h.

◆ m_check_ratio

const int CTxMemPool::m_check_ratio
private

Value n means that 1 times in n we check.

Definition at line 215 of file txmempool.h.

◆ m_dust_relay_feerate

const CFeeRate CTxMemPool::m_dust_relay_feerate

Definition at line 347 of file txmempool.h.

◆ m_expiry

const std::chrono::seconds CTxMemPool::m_expiry

Definition at line 345 of file txmempool.h.

◆ m_max_datacarrier_bytes

const std::optional<unsigned> CTxMemPool::m_max_datacarrier_bytes

Definition at line 349 of file txmempool.h.

◆ m_max_size_bytes

const int64_t CTxMemPool::m_max_size_bytes

Definition at line 344 of file txmempool.h.

◆ m_min_relay_feerate

const CFeeRate CTxMemPool::m_min_relay_feerate

Definition at line 346 of file txmempool.h.

◆ m_permit_bare_multisig

const bool CTxMemPool::m_permit_bare_multisig

Definition at line 348 of file txmempool.h.

◆ m_require_standard

const bool CTxMemPool::m_require_standard

Definition at line 350 of file txmempool.h.

◆ nTransactionsUpdated

std::atomic<uint32_t> CTxMemPool::nTransactionsUpdated {0}
private

Used by getblocktemplate to trigger CreateNewBlock() invocation.

Definition at line 217 of file txmempool.h.

◆ ROLLING_FEE_HALFLIFE

const int CTxMemPool::ROLLING_FEE_HALFLIFE = 60 * 60 * 12
static

Definition at line 255 of file txmempool.h.


The documentation for this class was generated from the following files: