60 std::vector<CTxMemPoolEntry::CTxMemPoolEntryRef>
ret;
63 for (; iter != mapNextTx.end() && iter->first->hash == entry.
GetTx().
GetHash(); ++iter) {
64 children.insert(iter->second);
66 for (
const auto& child : children) {
67 ret.emplace_back(*child);
75 std::vector<CTxMemPoolEntry::CTxMemPoolEntryRef>
ret;
76 std::set<Txid> inputs;
77 for (
const auto& txin : entry.
GetTx().
vin) {
78 inputs.insert(txin.prevout.hash);
80 for (
const auto& hash : inputs) {
81 std::optional<txiter> piter =
GetIter(hash);
83 ret.emplace_back(**piter);
95 for (
const Txid& hash : vHashesToUpdate | std::views::reverse) {
98 if (
it == mapTx.end()) {
101 auto iter = mapNextTx.lower_bound(
COutPoint(hash, 0));
103 for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) {
104 txiter childIter = iter->second;
105 assert(childIter != mapTx.end());
108 m_txgraph->AddDependency(*
it, *childIter);
113 auto txs_to_remove = m_txgraph->Trim();
114 for (
auto txptr : txs_to_remove) {
124 if (!entry)
return false;
132 if (ancestors.size() > 0) {
133 for (
auto ancestor : ancestors) {
134 if (ancestor != &entry) {
147 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
148 std::optional<txiter> piter =
GetIter(tx.
vin[i].prevout.hash);
150 staged_parents.insert(*piter);
154 for (
const auto& parent : staged_parents) {
156 for (
auto ancestor : parent_ancestors) {
166 opts.
check_ratio = std::clamp<int>(opts.check_ratio, 0, 1'000'000);
167 int64_t cluster_limit_bytes = opts.limits.cluster_size_vbytes * 40;
168 if (opts.max_size_bytes < 0 || (opts.max_size_bytes > 0 && opts.max_size_bytes < cluster_limit_bytes)) {
169 error =
strprintf(
_(
"-maxmempool must be at least %d MB"), std::ceil(cluster_limit_bytes / 1'000'000.0));
171 return std::move(opts);
183 return mapNextTx.count(outpoint);
199 m_txgraph->CommitStaging();
203 for (
size_t i=0; i<changeset->
m_entry_vec.size(); ++i) {
206 auto node_handle = changeset->
m_to_add.extract(tx_entry);
207 auto result = mapTx.insert(std::move(node_handle));
227 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
228 mapNextTx.insert(std::make_pair(&tx.
vin[i].prevout, newit));
239 m_total_fee += entry.
GetFee();
242 newit->idx_randomized = txns_randomized.size() - 1;
265 it->GetTx().GetHash().data(),
269 std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(
it->GetTime()).count()
272 for (
const CTxIn& txin :
it->GetTx().vin)
273 mapNextTx.erase(txin.prevout);
277 if (txns_randomized.size() > 1) {
279 txns_randomized[
it->idx_randomized] = std::move(txns_randomized.back());
280 txns_randomized[
it->idx_randomized].second->idx_randomized =
it->idx_randomized;
281 txns_randomized.pop_back();
282 if (txns_randomized.size() * 2 < txns_randomized.capacity()) {
283 txns_randomized.shrink_to_fit();
286 txns_randomized.clear();
289 totalTxSize -=
it->GetTxSize();
290 m_total_fee -=
it->GetFee();
291 cachedInnerUsage -=
it->DynamicMemoryUsage();
306 setDescendants.insert(mapTx.iterator_to(
static_cast<const CTxMemPoolEntry&
>(*tx)));
308 return mapTx.iterator_to(entry);
315 Assume(!m_have_changeset);
318 if (origit != mapTx.end()) {
319 txToRemove.insert(origit);
325 for (
unsigned int i = 0; i < origTx.
vout.size(); i++) {
327 if (
it == mapNextTx.end())
330 assert(nextit != mapTx.end());
331 txToRemove.insert(nextit);
347 Assume(!m_have_changeset);
350 for (indexed_transaction_set::const_iterator
it = mapTx.begin();
it != mapTx.end();
it++) {
351 if (check_final_and_mature(
it)) txToRemove.insert(
it);
358 for (indexed_transaction_set::const_iterator
it = mapTx.begin();
it != mapTx.end();
it++) {
370 if (
it != mapNextTx.end()) {
385 Assume(!m_have_changeset);
386 std::vector<RemovedMempoolTransactionInfo> txs_removed_for_block;
387 if (mapTx.size() || mapNextTx.size() || mapDeltas.size()) {
388 txs_removed_for_block.reserve(vtx.size());
389 for (
const auto& tx : vtx) {
390 txiter it = mapTx.find(tx->GetHash());
391 if (
it != mapTx.end()) {
394 txs_removed_for_block.emplace_back(*
it);
404 lastRollingFeeUpdate =
GetTime();
405 blockSinceLastRollingFeeBump =
true;
417 LogDebug(
BCLog::MEMPOOL,
"Checking mempool with %u transactions and %u inputs\n", (
unsigned int)mapTx.size(), (
unsigned int)mapNextTx.size());
419 uint64_t checkTotal = 0;
421 uint64_t innerUsage = 0;
424 m_txgraph->SanityCheck();
432 Assume(diagram.size() <= score_with_topo.size() + 1);
434 std::optional<Wtxid> last_wtxid = std::nullopt;
436 for (
const auto&
it : score_with_topo) {
437 checkTotal +=
it->GetTxSize();
438 check_total_fee +=
it->GetFee();
439 innerUsage +=
it->DynamicMemoryUsage();
448 std::set<CTxMemPoolEntry::CTxMemPoolEntryRef, CompareIteratorByHash> setParentCheck;
449 std::set<CTxMemPoolEntry::CTxMemPoolEntryRef, CompareIteratorByHash> setParentsStored;
452 indexed_transaction_set::const_iterator it2 = mapTx.find(txin.
prevout.
hash);
453 if (it2 != mapTx.end()) {
456 setParentCheck.insert(*it2);
464 auto it3 = mapNextTx.find(txin.
prevout);
465 assert(it3 != mapNextTx.end());
467 assert(&it3->second->GetTx() == &tx);
473 setParentsStored.insert(
dynamic_cast<const CTxMemPoolEntry&
>(txentry.get()));
475 assert(setParentCheck.size() == setParentsStored.size());
476 assert(std::equal(setParentCheck.begin(), setParentCheck.end(), setParentsStored.begin(), comp));
479 std::set<CTxMemPoolEntry::CTxMemPoolEntryRef, CompareIteratorByHash> setChildrenCheck;
480 std::set<CTxMemPoolEntry::CTxMemPoolEntryRef, CompareIteratorByHash> setChildrenStored;
481 auto iter = mapNextTx.lower_bound(
COutPoint(
it->GetTx().GetHash(), 0));
482 for (; iter != mapNextTx.end() && iter->first->hash ==
it->GetTx().GetHash(); ++iter) {
483 txiter childit = iter->second;
484 assert(childit != mapTx.end());
485 setChildrenCheck.insert(*childit);
488 setChildrenStored.insert(
dynamic_cast<const CTxMemPoolEntry&
>(txentry.get()));
490 assert(setChildrenCheck.size() == setChildrenStored.size());
491 assert(std::equal(setChildrenCheck.begin(), setChildrenCheck.end(), setChildrenStored.begin(), comp));
497 for (
const auto& input: tx.
vin) mempoolDuplicate.SpendCoin(input.prevout);
498 AddCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max());
500 for (
auto it = mapNextTx.cbegin();
it != mapNextTx.cend();
it++) {
501 indexed_transaction_set::const_iterator it2 =
it->second;
502 assert(it2 != mapTx.end());
505 assert(totalTxSize == checkTotal);
506 assert(m_total_fee == check_total_fee);
507 assert(innerUsage == cachedInnerUsage);
519 if (!j.has_value())
return false;
521 if (!i.has_value())
return true;
523 return m_txgraph->CompareMainOrder(*i.value(), *j.value()) < 0;
528 std::vector<indexed_transaction_set::const_iterator> iters;
531 iters.reserve(mapTx.size());
533 for (indexed_transaction_set::iterator mi = mapTx.begin(); mi != mapTx.end(); ++mi) {
537 return m_txgraph->CompareMainOrder(*a, *b) < 0;
546 std::vector<CTxMemPoolEntryRef>
ret;
547 ret.reserve(mapTx.size());
549 ret.emplace_back(*
it);
559 std::vector<TxMempoolInfo>
ret;
560 ret.reserve(mapTx.size());
561 for (
auto it : iters) {
571 const auto i = mapTx.find(txid);
572 return i == mapTx.end() ? nullptr : &(*i);
578 indexed_transaction_set::const_iterator i = mapTx.find(hash);
579 if (i == mapTx.end())
581 return i->GetSharedTx();
588 CAmount &delta = mapDeltas[hash];
591 if (
it != mapTx.end()) {
595 m_txgraph->SetTransactionFee(*
it,
it->GetModifiedFee());
599 mapDeltas.erase(hash);
600 LogPrintf(
"PrioritiseTransaction: %s (%sin mempool) delta cleared\n", hash.
ToString(),
it == mapTx.end() ?
"not " :
"");
602 LogPrintf(
"PrioritiseTransaction: %s (%sin mempool) fee += %s, new delta=%s\n",
604 it == mapTx.end() ?
"not " :
"",
614 std::map<Txid, CAmount>::const_iterator pos = mapDeltas.find(hash);
615 if (pos == mapDeltas.end())
617 const CAmount &delta = pos->second;
624 mapDeltas.erase(hash);
631 std::vector<delta_info> result;
632 result.reserve(mapDeltas.size());
633 for (
const auto& [txid, delta] : mapDeltas) {
634 const auto iter{mapTx.find(txid)};
635 const bool in_mempool{iter != mapTx.end()};
636 std::optional<CAmount> modified_fee;
637 if (in_mempool) modified_fee = iter->GetModifiedFee();
638 result.emplace_back(
delta_info{in_mempool, delta, modified_fee, txid});
645 const auto it = mapNextTx.find(prevout);
646 return it == mapNextTx.end() ? nullptr : &(
it->second->GetTx());
652 auto it = mapTx.find(txid);
653 return it != mapTx.end() ? std::make_optional(
it) : std::nullopt;
660 return it != mapTx.end() ? std::make_optional(
it) : std::nullopt;
666 for (
const auto& h : hashes) {
668 if (mi)
ret.insert(*mi);
676 std::vector<txiter>
ret;
677 ret.reserve(txids.size());
678 for (
const auto& txid : txids) {
688 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
709 if (outpoint.
n < ptx->vout.size()) {
721 for (
unsigned int n = 0; n < tx->vout.size(); ++n) {
741 if (m_unbroadcast_txids.erase(txid))
743 LogDebug(
BCLog::MEMPOOL,
"Removed %i from set of unbroadcast txns%s\n", txid.
GetHex(), (unchecked ?
" before confirmation that txn was sent out" :
""));
768 Assume(!m_have_changeset);
769 indexed_transaction_set::index<entry_time>::type::iterator
it = mapTx.get<
entry_time>().begin();
771 while (
it != mapTx.get<
entry_time>().end() &&
it->GetTime() < time) {
772 toremove.insert(mapTx.project<0>(
it));
776 for (
txiter removeit : toremove) {
785 if (!blockSinceLastRollingFeeBump || rollingMinimumFeeRate == 0)
786 return CFeeRate(llround(rollingMinimumFeeRate));
789 if (time > lastRollingFeeUpdate + 10) {
796 rollingMinimumFeeRate = rollingMinimumFeeRate / pow(2.0, (time - lastRollingFeeUpdate) / halflife);
797 lastRollingFeeUpdate = time;
800 rollingMinimumFeeRate = 0;
809 if (rate.
GetFeePerK() > rollingMinimumFeeRate) {
811 blockSinceLastRollingFeeBump =
false;
817 Assume(!m_have_changeset);
819 unsigned nTxnRemoved = 0;
823 const auto &[worst_chunk, feeperweight] = m_txgraph->GetWorstMainChunk();
833 maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed);
835 nTxnRemoved += worst_chunk.size();
837 std::vector<CTransaction> txn;
838 if (pvNoSpendsRemaining) {
839 txn.reserve(worst_chunk.size());
840 for (
auto ref : worst_chunk) {
846 for (
auto ref : worst_chunk) {
847 stage.insert(mapTx.iterator_to(
static_cast<const CTxMemPoolEntry&
>(*ref)));
849 for (
auto e : stage) {
852 if (pvNoSpendsRemaining) {
856 pvNoSpendsRemaining->push_back(txin.
prevout);
862 if (maxFeeRateRemoved >
CFeeRate(0)) {
871 size_t ancestor_count = ancestors.size();
872 size_t ancestor_size = 0;
874 for (
auto tx: ancestors) {
879 return {ancestor_count, ancestor_size, ancestor_fees};
885 size_t descendant_count = descendants.size();
886 size_t descendant_size = 0;
889 for (
auto tx: descendants) {
894 return {descendant_count, descendant_size, descendant_fees};
899 auto it = mapTx.find(txid);
900 ancestors = cluster_count = 0;
901 if (
it != mapTx.end()) {
903 ancestors = ancestor_count;
904 if (ancestorsize) *ancestorsize = ancestor_size;
905 if (ancestorfees) *ancestorfees = ancestor_fees;
919 m_load_tried = load_tried;
926 std::vector<CTxMemPool::txiter>
ret;
927 std::set<const CTxMemPoolEntry*> unique_cluster_representatives;
928 for (
auto txid : txids) {
929 auto it = mapTx.find(txid);
930 if (
it != mapTx.end()) {
932 if (unique_cluster_representatives.insert(
static_cast<const CTxMemPoolEntry*
>(&(**cluster.begin()))).second) {
933 for (
auto tx : cluster) {
939 if (
ret.size() > 500) {
953 return m_pool->m_txgraph->GetMainStagingDiagrams();
959 Assume(m_to_add.find(tx->GetHash()) == m_to_add.end());
960 Assume(!m_dependencies_processed);
963 m_dependencies_processed =
false;
966 m_pool->ApplyDelta(tx->GetHash(), delta);
969 auto newit = m_to_add.emplace(std::move(ref), tx,
fee, time, entry_height, entry_sequence, spends_coinbase, sigops_cost,
lp).first;
972 m_pool->m_txgraph->SetTransactionFee(*newit, newit->GetModifiedFee());
975 m_entry_vec.push_back(newit);
983 m_pool->m_txgraph->RemoveTransaction(*
it);
984 m_to_remove.insert(
it);
990 if (!m_dependencies_processed) {
991 ProcessDependencies();
1003 Assume(!m_dependencies_processed);
1004 for (
const auto& entryptr : m_entry_vec) {
1005 for (
const auto &txin : entryptr->GetSharedTx()->vin) {
1006 std::optional<txiter> piter = m_pool->GetIter(txin.
prevout.
hash);
1009 if (
it != m_to_add.end()) {
1010 piter = std::make_optional(
it);
1014 m_pool->m_txgraph->AddDependency(**piter, *entryptr);
1018 m_dependencies_processed =
true;
1025 if (!m_dependencies_processed) {
1026 ProcessDependencies();
1035 std::vector<FeePerWeight>
ret;
1037 ret.emplace_back(zero);
1041 std::vector<CTxMemPoolEntry::CTxMemPoolEntryRef> dummy;
1045 last_selection +=
ret.back();
1046 ret.emplace_back(last_selection);
int64_t CAmount
Amount in satoshis (Can be negative)
#define Assume(val)
Assume is the identity function.
An in-memory indexed chain of blocks.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
CCoinsView backed by another CCoinsView.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
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: CAmount / vB the feerate is represented internally as FeeFrac.
std::string ToString(const FeeEstimateMode &fee_estimate_mode=FeeEstimateMode::BTC_KVB) const
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
An outpoint - a combination of a transaction hash and an index n into its vout.
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const Wtxid & GetWitnessHash() const LIFETIMEBOUND
const Txid & GetHash() const LIFETIMEBOUND
const std::vector< CTxIn > vin
An input of a transaction.
CTxMemPool::setEntries m_to_remove
void Apply() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void StageRemoval(CTxMemPool::txiter it)
TxHandle StageAddition(const CTransactionRef &tx, const CAmount fee, int64_t time, unsigned int entry_height, uint64_t entry_sequence, bool spends_coinbase, int64_t sigops_cost, LockPoints lp)
util::Result< std::pair< std::vector< FeeFrac >, std::vector< FeeFrac > > > CalculateChunksForRBF()
Calculate the sorted chunks for the old and new mempool relating to the clusters that would be affect...
CTxMemPool::txiter TxHandle
CTxMemPool::indexed_transaction_set m_to_add
bool CheckMemPoolPolicyLimits()
Check if any cluster limits are exceeded.
void ProcessDependencies()
std::vector< CTxMemPool::txiter > m_entry_vec
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
const CTransaction & GetTx() const
void UpdateModifiedFee(CAmount fee_diff)
size_t DynamicMemoryUsage() const
int32_t GetTxSize() const
const CAmount & GetFee() const
CAmount GetModifiedFee() const
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)
std::atomic< unsigned int > nTransactionsUpdated
Used by getblocktemplate to trigger CreateNewBlock() invocation.
void Apply(CTxMemPool::ChangeSet *changeset) EXCLUSIVE_LOCKS_REQUIRED(cs)
void PrioritiseTransaction(const Txid &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
std::unique_ptr< ChangeSet > GetChangeSet() EXCLUSIVE_LOCKS_REQUIRED(cs)
bool CompareMiningScoreWithTopology(const Wtxid &hasha, const Wtxid &hashb) const
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it)
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...
setEntries GetIterSet(const std::set< Txid > &hashes) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Translate a set of hashes into a set of pool iterators to avoid repeated lookups.
void ClearPrioritisation(const Txid &hash) EXCLUSIVE_LOCKS_REQUIRED(cs)
std::optional< txiter > GetIter(const Txid &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given hash, if found.
bool GetLoadTried() const
void StopBlockBuilding() const EXCLUSIVE_LOCKS_REQUIRED(cs)
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 check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
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 GetTransactionAncestry(const Txid &txid, size_t &ancestors, size_t &cluster_count, size_t *ancestorsize=nullptr, CAmount *ancestorfees=nullptr) const
Calculate the ancestor and cluster count for the given transaction.
void UpdateTransactionsFromBlock(const std::vector< Txid > &vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs
UpdateTransactionsFromBlock is called when adding transactions from a disconnected block back to the ...
void AddTransactionsUpdated(unsigned int n)
bool HasDescendants(const Txid &txid) const
std::vector< indexed_transaction_set::const_iterator > GetSortedScoreWithTopology() const EXCLUSIVE_LOCKS_REQUIRED(cs)
void StartBlockBuilding() const EXCLUSIVE_LOCKS_REQUIRED(cs)
CTransactionRef get(const Txid &hash) const
size_t DynamicMemoryUsage() const
std::vector< TxMempoolInfo > infoAll() const
CTxMemPool(Options opts, bilingual_str &error)
Create a new CTxMemPool.
void addNewTransaction(CTxMemPool::txiter it) EXCLUSIVE_LOCKS_REQUIRED(cs)
void removeUnchecked(txiter entry, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Before calling removeUnchecked for a given transaction, UpdateForRemoveFromMempool must be called on ...
void RemoveUnbroadcastTx(const Txid &txid, const bool unchecked=false)
Removes a transaction from the unbroadcast set.
int Expire(std::chrono::seconds time) EXCLUSIVE_LOCKS_REQUIRED(cs)
Expire all transaction (and their dependencies) in the mempool older than time.
void IncludeBuilderChunk() const EXCLUSIVE_LOCKS_REQUIRED(cs)
void removeForReorg(CChain &chain, std::function< bool(txiter)> filter_final_and_mature) EXCLUSIVE_LOCKS_REQUIRED(cs
After reorg, filter the entries that would no longer be valid in the next block, and update the entri...
std::vector< FeePerWeight > GetFeerateDiagram() const EXCLUSIVE_LOCKS_REQUIRED(cs)
std::tuple< size_t, size_t, CAmount > CalculateDescendantData(const CTxMemPoolEntry &entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
bool exists(const Txid &txid) const
std::vector< txiter > GetIterVec(const std::vector< Txid > &txids) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Translate a list of hashes into a list of mempool iterators to avoid repeated lookups.
static const int ROLLING_FEE_HALFLIFE
std::set< txiter, CompareIteratorByHash > setEntries
std::vector< CTxMemPoolEntry::CTxMemPoolEntryRef > GetParents(const CTxMemPoolEntry &entry) const
void ApplyDelta(const Txid &hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs)
void RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove a set of transactions from the mempool.
void removeForBlock(const std::vector< CTransactionRef > &vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs)
std::vector< delta_info > GetPrioritisedTransactions() const EXCLUSIVE_LOCKS_REQUIRED(!cs)
Return a vector of all entries in mapDeltas with their corresponding delta_info.
std::vector< txiter > GatherClusters(const std::vector< Txid > &txids) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Collect the entire cluster of connected transactions for each transaction in txids.
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.
bool CheckPolicyLimits(const CTransactionRef &tx)
const CTransaction * GetConflictTx(const COutPoint &prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Get the transaction in the pool that spends the same prevout.
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of given transaction.
std::tuple< size_t, size_t, CAmount > CalculateAncestorData(const CTxMemPoolEntry &entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
std::vector< CTxMemPoolEntry::CTxMemPoolEntryRef > GetChildren(const CTxMemPoolEntry &entry) const
setEntries CalculateMemPoolAncestors(const CTxMemPoolEntry &entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Calculate all in-mempool ancestors of entry (not including the tx itself)
void SetLoadTried(bool load_tried)
Set whether or not an initial attempt to load the persisted mempool was made (regardless of whether t...
std::vector< CTxMemPoolEntryRef > entryAll() const EXCLUSIVE_LOCKS_REQUIRED(cs)
bool isSpent(const COutPoint &outpoint) const
FeePerWeight GetBlockBuilderChunk(std::vector< CTxMemPoolEntry::CTxMemPoolEntryRef > &entries) const EXCLUSIVE_LOCKS_REQUIRED(cs)
const CTxMemPoolEntry * GetEntry(const Txid &txid) const LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(cs)
unsigned int GetTransactionsUpdated() const
@ MAIN
Always refers to the main graph, whether staging is present or not.
@ TOP
Refers to staging if it exists, main otherwise.
void MempoolTransactionsRemovedForBlock(const std::vector< RemovedMempoolTransactionInfo > &, unsigned int nBlockHeight)
void TransactionRemovedFromMempool(const CTransactionRef &, MemPoolRemovalReason, uint64_t mempool_sequence)
std::string ToString() const
std::string GetHex() const
constexpr const std::byte * data() 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.
static int32_t GetTransactionWeight(const CTransaction &tx)
static const int WITNESS_SCALE_FACTOR
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
#define LogDebug(category,...)
std::string RemovalReasonToString(const MemPoolRemovalReason &r) noexcept
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.
@ EXPIRY
Expired from mempool.
@ REPLACED
Removed for replacement.
@ CONFLICT
Removed for conflict with in-block transaction.
@ REORG
Removed for reorganization.
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
bool CheckTxInputs(const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight, CAmount &txfee)
Check whether all inputs of this transaction are valid (no double spends and amounts) This does not m...
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
static size_t MallocUsage(size_t alloc)
Compute the total memory used by allocating alloc bytes.
T SaturatingAdd(const T i, const T j) noexcept
unsigned int nBytesPerSigOp
int64_t GetSigOpsAdjustedWeight(int64_t weight, int64_t sigop_cost, unsigned int bytes_per_sigop)
static FeePerVSize ToFeePerVSize(FeePerWeight feerate)
std::shared_ptr< const CTransaction > CTransactionRef
CBlockIndex * maxInputBlock
unsigned cluster_count
The maximum number of transactions in a cluster.
int64_t cluster_size_vbytes
The maximum allowed size in virtual bytes of a cluster.
Options struct containing options for constructing a CTxMemPool.
ValidationSignals * signals
CFeeRate incremental_relay_feerate
#define AssertLockNotHeld(cs)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
#define TRACEPOINT(context,...)
consteval auto _(util::TranslatedLiteral str)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
std::unique_ptr< TxGraph > MakeTxGraph(unsigned max_cluster_count, uint64_t max_cluster_size, uint64_t acceptable_iters) noexcept
Construct a new TxGraph with the specified limit on the number of transactions within a cluster,...
static CTxMemPool::Options && Flatten(CTxMemPool::Options &&opts, bilingual_str &error)
TRACEPOINT_SEMAPHORE(mempool, added)
bool TestLockPointValidity(CChain &active_chain, const LockPoints &lp)
Test whether the LockPoints height and time are still valid on the current chain.
static constexpr uint64_t ACCEPTABLE_ITERS
How many linearization iterations required for TxGraph clusters to have "acceptable" quality,...
static constexpr uint64_t POST_CHANGE_WORK
How much work we ask TxGraph to do after a mempool change occurs (either due to a changeset being app...
static const uint32_t MEMPOOL_HEIGHT
Fake height value used in Coin to signify they are only in the memory pool (since 0....
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.