The node's memory pool of unconfirmed transactions.

Synopsis

Declared in <txmempool.h>

class CTxMemPool;

Types

Name

Description

ChangeSet

Stages a batch of mempool additions and associated removals to be applied atomically.

delta_info

Prioritisation information for a single entry in mapDeltas.

Type Aliases

Name

Description

Limits

Cluster size and count limits applied to the mempool.

Options

Configuration options controlling mempool behavior and limits.

indexed_transaction_set

Boost multi‐index container type storing mempool entries indexed by txid, wtxid, and entry time.

setEntries

A set of mempool iterators ordered by transaction hash.

txiter

Const iterator into mapTx over the txid‐ordered index.

Member Functions

Name

Description

CTxMemPool [constructor]

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.

AddTransactionsUpdated

Increase the transaction update counter by the given amount.

AddUnbroadcastTx

Adds a transaction to the unbroadcast set

ApplyDelta

Add the stored fee delta for the given txid to the supplied fee value.

CalculateAncestorData

Compute the count, aggregate size, and aggregate fee of an entry's in‐mempool ancestors.

CalculateDescendantData

Compute the count, aggregate size, and aggregate fee of an entry's in‐mempool descendants.

CalculateDescendants

CalculateDescendants overloads

CalculateMemPoolAncestors

Calculate all in‐mempool ancestors of entry (not including the tx itself)

CheckPolicyLimits

Check whether the given transaction would satisfy the mempool's cluster policy limits.

ClearPrioritisation

Remove any stored fee delta for the given txid.

DynamicMemoryUsage

Returns the dynamic memory usage of the mempool, in bytes.

Expire

Expire all transaction (and their dependencies) in the mempool older than time. Return the number of removed transactions.

ExtractBestByMiningScoreWithTopology

Look up wtxids in the mempool and (partially) sort by mining score.

GatherClusters

Collect the entire cluster of connected transactions for each transaction in txids. All txids must correspond to transaction entries in the mempool, otherwise this returns an empty vector. This call will also exit early and return an empty vector if it collects 500 or more transactions as a DoS protection.

GetAncestorCount

Returns the number of in‐mempool ancestors of the given entry (including itself).

GetAndIncrementSequence

Guards this internal counter for external reporting

GetBlockBuilderChunk

Retrieve the current chunk of transactions from the block builder in mining order.

GetChangeSet

Create the single outstanding changeset for staging mempool additions and removals.

GetChildren

Returns the direct in‐mempool children of the given entry.

GetCluster

Returns all mempool entries in the same cluster as the given transaction.

GetConflictTx

Get the transaction in the pool that spends the same prevout

GetDescendantCount

GetDescendantCount overloads

GetEntry

Returns a pointer to the mempool entry for the given txid, or nullptr if absent.

GetFeerateDiagram

Returns the mempool's fee‐rate diagram, i.e. the chunk fee rates in mining order.

GetIter

GetIter overloads

GetIterSet

Translate a set of hashes into a set of pool iterators to avoid repeated lookups. Does not require that all of the hashes correspond to actual transactions in the mempool, only returns the ones that exist.

GetIterVec

Translate a list of hashes into a list of mempool iterators to avoid repeated lookups. The nth element in txids becomes the nth element in the returned vector. If any of the txids don't actually exist in the mempool, returns an empty vector.

GetLoadTried

Report whether an initial attempt to load the persisted mempool was made.

GetMainChunkFeerate

Returns the fee rate of the chunk containing the given entry in the main graph.

GetMinFee

The minimum fee to get into the mempool, which may itself not be enough for larger‐sized transactions. The m_incremental_relay_feerate policy variable is used to bound the time it takes the fee rate to go back down all the way to 0. When the feerate would otherwise be half of this, it is set to 0 instead.

GetParents

Returns the direct in‐mempool parents of the given entry.

GetPrioritisedTransactions

Return a vector of all entries in mapDeltas with their corresponding delta_info.

GetSequence

Returns the current mempool sequence number without incrementing it.

GetTotalFee

Returns the sum of base fees of all mempool transactions.

GetTotalTxSize

Returns the sum of virtual sizes of all mempool transactions.

GetTransactionAncestry

Calculate the ancestor and cluster count for the given transaction. The counts include the transaction itself. When ancestors is non‐zero (ie, the transaction itself is in the mempool), ancestorsize and ancestorfees will also be set to the appropriate values.

GetTransactionsUpdated

Returns the running count of transaction updates, used to trigger block template regeneration.

GetUnbroadcastTxs

Returns transactions in unbroadcast set

GetUniqueClusterCount

Returns the number of distinct clusters spanned by the given set of entries.

HasDescendants

Returns whether the transaction with the given txid has any in‐mempool descendants.

HasNoInputsOf

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.

IncludeBuilderChunk

Include the current chunk in the block being built and advance the builder.

IsUnbroadcastTx

Returns whether a txid is in the unbroadcast set

PrioritiseTransaction

Affect CreateNewBlock prioritisation of transactions

RemoveUnbroadcastTx

Removes a transaction from the unbroadcast set

SetLoadTried

Set whether or not an initial attempt to load the persisted mempool was made (regardless of whether the attempt was successful or not)

SkipBuilderChunk

Skip the current chunk without including it and advance the builder.

StartBlockBuilding

Begin building a block by creating the block builder from the transaction graph.

StopBlockBuilding

Finish block building and release the block builder.

TrimToSize

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.

UpdateTransactionsFromBlock

UpdateTransactionsFromBlock is called when adding transactions from a disconnected block back to the mempool, new mempool entries may have children in the mempool (which is generally not the case when otherwise adding transactions).

check

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.

entryAll

Returns every mempool entry.

exists

exists overloads

get

get overloads

info

Returns descriptive information about the transaction with the given hash.

infoAll

Returns descriptive information for every mempool transaction.

info_for_relay

Returns info for a transaction if its entry_sequence < last_sequence

isSpent

Returns whether the given outpoint is spent by a transaction in the mempool.

removeForBlock

Remove transactions confirmed in a block (and any that conflict with them) from the mempool.

removeForReorg

After reorg, filter the entries that would no longer be valid in the next block, and update the entries' cached LockPoints if needed. The mempool does not have any knowledge of consensus rules. It just applies the callable function and removes the ones for which it returns true.

removeRecursive

Remove a transaction from the mempool along with any descendants. If the transaction is not already in the mempool, find any descendants and remove them.

size

Returns the number of transactions in the mempool.

Data Members

Name

Description

cs

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

m_builder

Block builder used to iterate mempool chunks in mining order while assembling a block.

m_have_changeset

Whether a changeset is currently outstanding against this mempool.

m_opts

The configuration options this mempool was constructed with.

m_txgraph

Transaction‐graph abstraction managing parent/child relationships, clusters, and ordering.

mapDeltas

Maps a txid to the fee delta applied to it via PrioritiseTransaction().

mapNextTx

Maps each spent outpoint to the in‐mempool transaction that spends it.

mapTx

The multi‐index container holding every mempool entry.

txns_randomized

All transactions in mapTx with their wtxids, in arbitrary order

Static Data Members

Name

Description

ROLLING_FEE_HALFLIFE

Half‐life, in seconds, of the exponential decay applied to the rolling minimum fee rate.

Protected Member Functions

Name

Description

GetMinFee

Compute the minimum fee rate to enter a mempool bounded by the given size limit.

trackPackageRemoved

Update the rolling minimum fee rate to account for a package removal at the given fee rate.

Protected Data Members

Name

Description

blockSinceLastRollingFeeBump

whether a block has been connected since the rolling fee was last bumped

cachedInnerUsage

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

lastRollingFeeUpdate

time the rolling minimum fee rate was last decayed

m_load_tried

whether an attempt to load the persisted mempool has been made

m_sequence_number

In‐memory counter incremented every time a transaction is added to or removed from the mempool, used for external mempool tracking.

m_total_fee

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

nTransactionsUpdated

Used by getblocktemplate to trigger CreateNewBlock() invocation

rollingMinimumFeeRate

minimum fee to get into the pool, decreases exponentially

totalTxSize

sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discounted. Defined in BIP 141.

Friends

Name

Description

CTxMemPool::ChangeSet

Stages a batch of mempool additions and associated removals to be applied atomically.

Non-Member Functions

Name

Description

EnsureAnyMemPool

Get the mempool from an opaque RPC context, asserting it is present.

EnsureMemPool

Get the mempool from a node context, asserting it is present.

MempoolInfoToJSON

Mempool information to JSON

MempoolToJSON

Mempool to JSON

PackageTRUCChecks

Must be called for every transaction that is submitted within a package, even if not TRUC.

SingleTRUCChecks

Must be called for every transaction, even if not TRUC. Not strictly necessary for transactions accepted through AcceptMultipleTransactions.

node::DumpMempool

Dump the mempool to a file.

node::LoadMempool

Import the file and attempt to add its contents to the mempool.

Created with MrDocs