[#CTxMemPool]
= CTxMemPool
:mrdocs:

The node&apos;s memory pool of unconfirmed transactions&period;

== Synopsis

Declared in `&lt;txmempool&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class CTxMemPool;
----

== Types

[cols="1,4"]
|===
| Name| Description
| xref:CTxMemPool/ChangeSet.adoc[`ChangeSet`] 
| Stages a batch of mempool additions and associated removals to be applied atomically&period;
| xref:CTxMemPool/delta_info.adoc[`delta&lowbar;info`] 
| Prioritisation information for a single entry in mapDeltas&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:CTxMemPool/Limits.adoc[`Limits`] 
| Cluster size and count limits applied to the mempool&period;
| xref:CTxMemPool/Options.adoc[`Options`] 
| Configuration options controlling mempool behavior and limits&period;
| xref:CTxMemPool/indexed_transaction_set.adoc[`indexed&lowbar;transaction&lowbar;set`] 
| Boost multi&hyphen;index container type storing mempool entries indexed by txid, wtxid, and entry time&period;
| xref:CTxMemPool/setEntries.adoc[`setEntries`] 
| A set of mempool iterators ordered by transaction hash&period;
| xref:CTxMemPool/txiter.adoc[`txiter`] 
| Const iterator into mapTx over the txid&hyphen;ordered index&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CTxMemPool/2constructor.adoc[`CTxMemPool`]         [.small]#[constructor]#
| Create a new CTxMemPool&period; Sanity checks will be off by default for performance, because otherwise accepting transactions becomes O(N&circ;2) where N is the number of transactions in the pool&period;
| xref:CTxMemPool/AddTransactionsUpdated.adoc[`AddTransactionsUpdated`] 
| Increase the transaction update counter by the given amount&period;
| xref:CTxMemPool/AddUnbroadcastTx.adoc[`AddUnbroadcastTx`] 
| Adds a transaction to the unbroadcast set
| xref:CTxMemPool/ApplyDelta.adoc[`ApplyDelta`] 
| Add the stored fee delta for the given txid to the supplied fee value&period;
| xref:CTxMemPool/CalculateAncestorData.adoc[`CalculateAncestorData`] 
| Compute the count, aggregate size, and aggregate fee of an entry&apos;s in&hyphen;mempool ancestors&period;
| xref:CTxMemPool/CalculateDescendantData.adoc[`CalculateDescendantData`] 
| Compute the count, aggregate size, and aggregate fee of an entry&apos;s in&hyphen;mempool descendants&period;
| xref:CTxMemPool/CalculateDescendants-04.adoc[`CalculateDescendants`] 
| `CalculateDescendants` overloads
| xref:CTxMemPool/CalculateMemPoolAncestors.adoc[`CalculateMemPoolAncestors`] 
| Calculate all in&hyphen;mempool ancestors of entry (not including the tx itself)
| xref:CTxMemPool/CheckPolicyLimits.adoc[`CheckPolicyLimits`] 
| Check whether the given transaction would satisfy the mempool&apos;s cluster policy limits&period;
| xref:CTxMemPool/ClearPrioritisation.adoc[`ClearPrioritisation`] 
| Remove any stored fee delta for the given txid&period;
| xref:CTxMemPool/DynamicMemoryUsage.adoc[`DynamicMemoryUsage`] 
| Returns the dynamic memory usage of the mempool, in bytes&period;
| xref:CTxMemPool/Expire.adoc[`Expire`] 
| Expire all transaction (and their dependencies) in the mempool older than time&period; Return the number of removed transactions&period;
| xref:CTxMemPool/ExtractBestByMiningScoreWithTopology.adoc[`ExtractBestByMiningScoreWithTopology`] 
| Look up wtxids in the mempool and (partially) sort by mining score&period;
| xref:CTxMemPool/GatherClusters.adoc[`GatherClusters`] 
| Collect the entire cluster of connected transactions for each transaction in txids&period; All txids must correspond to transaction entries in the mempool, otherwise this returns an empty vector&period; This call will also exit early and return an empty vector if it collects 500 or more transactions as a DoS protection&period;
| xref:CTxMemPool/GetAncestorCount.adoc[`GetAncestorCount`] 
| Returns the number of in&hyphen;mempool ancestors of the given entry (including itself)&period;
| xref:CTxMemPool/GetAndIncrementSequence.adoc[`GetAndIncrementSequence`] 
| Guards this internal counter for external reporting
| xref:CTxMemPool/GetBlockBuilderChunk.adoc[`GetBlockBuilderChunk`] 
| Retrieve the current chunk of transactions from the block builder in mining order&period;
| xref:CTxMemPool/GetChangeSet.adoc[`GetChangeSet`] 
| Create the single outstanding changeset for staging mempool additions and removals&period;
| xref:CTxMemPool/GetChildren.adoc[`GetChildren`] 
| Returns the direct in&hyphen;mempool children of the given entry&period;
| xref:CTxMemPool/GetCluster.adoc[`GetCluster`] 
| Returns all mempool entries in the same cluster as the given transaction&period;
| xref:CTxMemPool/GetConflictTx.adoc[`GetConflictTx`] 
| Get the transaction in the pool that spends the same prevout
| xref:CTxMemPool/GetDescendantCount-03d.adoc[`GetDescendantCount`] 
| `GetDescendantCount` overloads
| xref:CTxMemPool/GetEntry.adoc[`GetEntry`] 
| Returns a pointer to the mempool entry for the given txid, or nullptr if absent&period;
| xref:CTxMemPool/GetFeerateDiagram.adoc[`GetFeerateDiagram`] 
| Returns the mempool&apos;s fee&hyphen;rate diagram, i&period;e&period; the chunk fee rates in mining order&period;
| xref:CTxMemPool/GetIter-0b.adoc[`GetIter`] 
| `GetIter` overloads
| xref:CTxMemPool/GetIterSet.adoc[`GetIterSet`] 
| Translate a set of hashes into a set of pool iterators to avoid repeated lookups&period; Does not require that all of the hashes correspond to actual transactions in the mempool, only returns the ones that exist&period;
| xref:CTxMemPool/GetIterVec.adoc[`GetIterVec`] 
| Translate a list of hashes into a list of mempool iterators to avoid repeated lookups&period; The nth element in txids becomes the nth element in the returned vector&period; If any of the txids don&apos;t actually exist in the mempool, returns an empty vector&period;
| xref:CTxMemPool/GetLoadTried.adoc[`GetLoadTried`] 
| Report whether an initial attempt to load the persisted mempool was made&period;
| xref:CTxMemPool/GetMainChunkFeerate.adoc[`GetMainChunkFeerate`] 
| Returns the fee rate of the chunk containing the given entry in the main graph&period;
| xref:CTxMemPool/GetMinFee-0c.adoc[`GetMinFee`] 
| The minimum fee to get into the mempool, which may itself not be enough for larger&hyphen;sized transactions&period; The m&lowbar;incremental&lowbar;relay&lowbar;feerate policy variable is used to bound the time it takes the fee rate to go back down all the way to 0&period; When the feerate would otherwise be half of this, it is set to 0 instead&period;
| xref:CTxMemPool/GetParents.adoc[`GetParents`] 
| Returns the direct in&hyphen;mempool parents of the given entry&period;
| xref:CTxMemPool/GetPrioritisedTransactions.adoc[`GetPrioritisedTransactions`] 
| Return a vector of all entries in mapDeltas with their corresponding delta&lowbar;info&period;
| xref:CTxMemPool/GetSequence.adoc[`GetSequence`] 
| Returns the current mempool sequence number without incrementing it&period;
| xref:CTxMemPool/GetTotalFee.adoc[`GetTotalFee`] 
| Returns the sum of base fees of all mempool transactions&period;
| xref:CTxMemPool/GetTotalTxSize.adoc[`GetTotalTxSize`] 
| Returns the sum of virtual sizes of all mempool transactions&period;
| xref:CTxMemPool/GetTransactionAncestry.adoc[`GetTransactionAncestry`] 
| Calculate the ancestor and cluster count for the given transaction&period; The counts include the transaction itself&period; When ancestors is non&hyphen;zero (ie, the transaction itself is in the mempool), ancestorsize and ancestorfees will also be set to the appropriate values&period;
| xref:CTxMemPool/GetTransactionsUpdated.adoc[`GetTransactionsUpdated`] 
| Returns the running count of transaction updates, used to trigger block template regeneration&period;
| xref:CTxMemPool/GetUnbroadcastTxs.adoc[`GetUnbroadcastTxs`] 
| Returns transactions in unbroadcast set
| xref:CTxMemPool/GetUniqueClusterCount.adoc[`GetUniqueClusterCount`] 
| Returns the number of distinct clusters spanned by the given set of entries&period;
| xref:CTxMemPool/HasDescendants.adoc[`HasDescendants`] 
| Returns whether the transaction with the given txid has any in&hyphen;mempool descendants&period;
| xref:CTxMemPool/HasNoInputsOf.adoc[`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&period;
| xref:CTxMemPool/IncludeBuilderChunk.adoc[`IncludeBuilderChunk`] 
| Include the current chunk in the block being built and advance the builder&period;
| xref:CTxMemPool/IsUnbroadcastTx.adoc[`IsUnbroadcastTx`] 
| Returns whether a txid is in the unbroadcast set
| xref:CTxMemPool/PrioritiseTransaction.adoc[`PrioritiseTransaction`] 
| Affect CreateNewBlock prioritisation of transactions
| xref:CTxMemPool/RemoveUnbroadcastTx.adoc[`RemoveUnbroadcastTx`] 
| Removes a transaction from the unbroadcast set
| xref:CTxMemPool/SetLoadTried.adoc[`SetLoadTried`] 
| Set whether or not an initial attempt to load the persisted mempool was made (regardless of whether the attempt was successful or not)
| xref:CTxMemPool/SkipBuilderChunk.adoc[`SkipBuilderChunk`] 
| Skip the current chunk without including it and advance the builder&period;
| xref:CTxMemPool/StartBlockBuilding.adoc[`StartBlockBuilding`] 
| Begin building a block by creating the block builder from the transaction graph&period;
| xref:CTxMemPool/StopBlockBuilding.adoc[`StopBlockBuilding`] 
| Finish block building and release the block builder&period;
| xref:CTxMemPool/TrimToSize.adoc[`TrimToSize`] 
| Remove transactions from the mempool until its dynamic size is &lt;&equals; sizelimit&period; 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&period;
| xref:CTxMemPool/UpdateTransactionsFromBlock.adoc[`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)&period;
| xref:CTxMemPool/check.adoc[`check`] 
| If sanity&hyphen;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)&period; If sanity&hyphen;checking is turned off, check does nothing&period;
| xref:CTxMemPool/entryAll.adoc[`entryAll`] 
| Returns every mempool entry&period;
| xref:CTxMemPool/exists-0c.adoc[`exists`] 
| `exists` overloads
| xref:CTxMemPool/get-0ebc.adoc[`get`] 
| `get` overloads
| xref:CTxMemPool/info.adoc[`info`] 
| Returns descriptive information about the transaction with the given hash&period;
| xref:CTxMemPool/infoAll.adoc[`infoAll`] 
| Returns descriptive information for every mempool transaction&period;
| xref:CTxMemPool/info_for_relay.adoc[`info&lowbar;for&lowbar;relay`] 
| Returns info for a transaction if its entry&lowbar;sequence &lt; last&lowbar;sequence
| xref:CTxMemPool/isSpent.adoc[`isSpent`] 
| Returns whether the given outpoint is spent by a transaction in the mempool&period;
| xref:CTxMemPool/removeForBlock.adoc[`removeForBlock`] 
| Remove transactions confirmed in a block (and any that conflict with them) from the mempool&period;
| xref:CTxMemPool/removeForReorg.adoc[`removeForReorg`] 
| After reorg, filter the entries that would no longer be valid in the next block, and update the entries&apos; cached LockPoints if needed&period; The mempool does not have any knowledge of consensus rules&period; It just applies the callable function and removes the ones for which it returns true&period;
| xref:CTxMemPool/removeRecursive-03.adoc[`removeRecursive`] 
| Remove a transaction from the mempool along with any descendants&period; If the transaction is not already in the mempool, find any descendants and remove them&period;
| xref:CTxMemPool/size.adoc[`size`] 
| Returns the number of transactions in the mempool&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:CTxMemPool/cs.adoc[`cs`] 
| This mutex needs to be locked when accessing `mapTx` or other members that are guarded by it&period;
| xref:CTxMemPool/m_builder.adoc[`m&lowbar;builder`] 
| Block builder used to iterate mempool chunks in mining order while assembling a block&period;
| xref:CTxMemPool/m_have_changeset.adoc[`m&lowbar;have&lowbar;changeset`] 
| Whether a changeset is currently outstanding against this mempool&period;
| xref:CTxMemPool/m_opts.adoc[`m&lowbar;opts`] 
| The configuration options this mempool was constructed with&period;
| xref:CTxMemPool/m_txgraph.adoc[`m&lowbar;txgraph`] 
| Transaction&hyphen;graph abstraction managing parent&sol;child relationships, clusters, and ordering&period;
| xref:CTxMemPool/mapDeltas.adoc[`mapDeltas`] 
| Maps a txid to the fee delta applied to it via PrioritiseTransaction()&period;
| xref:CTxMemPool/mapNextTx.adoc[`mapNextTx`] 
| Maps each spent outpoint to the in&hyphen;mempool transaction that spends it&period;
| xref:CTxMemPool/mapTx.adoc[`mapTx`] 
| The multi&hyphen;index container holding every mempool entry&period;
| xref:CTxMemPool/txns_randomized.adoc[`txns&lowbar;randomized`] 
| All transactions in mapTx with their wtxids, in arbitrary order
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:CTxMemPool/ROLLING_FEE_HALFLIFE.adoc[`ROLLING&lowbar;FEE&lowbar;HALFLIFE`] 
| Half&hyphen;life, in seconds, of the exponential decay applied to the rolling minimum fee rate&period;
|===


== Protected Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CTxMemPool/GetMinFee-0e.adoc[`GetMinFee`] 
| Compute the minimum fee rate to enter a mempool bounded by the given size limit&period;
| xref:CTxMemPool/trackPackageRemoved.adoc[`trackPackageRemoved`] 
| Update the rolling minimum fee rate to account for a package removal at the given fee rate&period;
|===


== Protected Data Members

[cols="1,4"]
|===
| Name| Description
| xref:CTxMemPool/blockSinceLastRollingFeeBump.adoc[`blockSinceLastRollingFeeBump`] 
| whether a block has been connected since the rolling fee was last bumped
| xref:CTxMemPool/cachedInnerUsage.adoc[`cachedInnerUsage`] 
| sum of dynamic memory usage of all the map elements (NOT the maps themselves)
| xref:CTxMemPool/lastRollingFeeUpdate.adoc[`lastRollingFeeUpdate`] 
| time the rolling minimum fee rate was last decayed
| xref:CTxMemPool/m_load_tried.adoc[`m&lowbar;load&lowbar;tried`] 
| whether an attempt to load the persisted mempool has been made
| xref:CTxMemPool/m_sequence_number.adoc[`m&lowbar;sequence&lowbar;number`] 
| In&hyphen;memory counter incremented every time a transaction is added to or removed from the mempool, used for external mempool tracking&period;
| xref:CTxMemPool/m_total_fee.adoc[`m&lowbar;total&lowbar;fee`] 
| sum of all mempool tx&apos;s fees (NOT modified fee)
| xref:CTxMemPool/nTransactionsUpdated.adoc[`nTransactionsUpdated`] 
| Used by getblocktemplate to trigger CreateNewBlock() invocation
| xref:CTxMemPool/rollingMinimumFeeRate.adoc[`rollingMinimumFeeRate`] 
| minimum fee to get into the pool, decreases exponentially
| xref:CTxMemPool/totalTxSize.adoc[`totalTxSize`] 
| sum of all mempool tx&apos;s virtual sizes&period; Differs from serialized tx size since witness data is discounted&period; Defined in BIP 141&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:CTxMemPool/ChangeSet.adoc[CTxMemPool::ChangeSet]`
| Stages a batch of mempool additions and associated removals to be applied atomically&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:EnsureAnyMemPool.adoc[`EnsureAnyMemPool`]
| Get the mempool from an opaque RPC context, asserting it is present&period;
| xref:EnsureMemPool.adoc[`EnsureMemPool`]
| Get the mempool from a node context, asserting it is present&period;
| xref:MempoolInfoToJSON.adoc[`MempoolInfoToJSON`]
| Mempool information to JSON
| xref:MempoolToJSON.adoc[`MempoolToJSON`]
| Mempool to JSON
| xref:PackageTRUCChecks.adoc[`PackageTRUCChecks`]
| Must be called for every transaction that is submitted within a package, even if not TRUC&period;
| xref:SingleTRUCChecks.adoc[`SingleTRUCChecks`]
| Must be called for every transaction, even if not TRUC&period; Not strictly necessary for transactions accepted through AcceptMultipleTransactions&period;
| xref:node/DumpMempool.adoc[`node&colon;&colon;DumpMempool`]
| Dump the mempool to a file&period;
| xref:node/LoadMempool.adoc[`node&colon;&colon;LoadMempool`]
| Import the file and attempt to add its contents to the mempool&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
