Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const { | ||||
return f1 > f2; | return f1 > f2; | ||||
} | } | ||||
}; | }; | ||||
// Multi_index tag names | // Multi_index tag names | ||||
struct descendant_score {}; | struct descendant_score {}; | ||||
struct entry_time {}; | struct entry_time {}; | ||||
struct mining_score {}; | |||||
struct ancestor_score {}; | struct ancestor_score {}; | ||||
/** | /** | ||||
* Information about a mempool transaction. | * Information about a mempool transaction. | ||||
*/ | */ | ||||
struct TxMempoolInfo { | struct TxMempoolInfo { | ||||
/** The transaction itself */ | /** The transaction itself */ | ||||
CTransactionRef tx; | CTransactionRef tx; | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
* - a non-standard transaction. | * - a non-standard transaction. | ||||
* | * | ||||
* CTxMemPool::mapTx, and CTxMemPoolEntry bookkeeping: | * CTxMemPool::mapTx, and CTxMemPoolEntry bookkeeping: | ||||
* | * | ||||
* mapTx is a boost::multi_index that sorts the mempool on 4 criteria: | * mapTx is a boost::multi_index that sorts the mempool on 4 criteria: | ||||
* - transaction hash | * - transaction hash | ||||
* - feerate [we use max(feerate of tx, feerate of tx with all descendants)] | * - feerate [we use max(feerate of tx, feerate of tx with all descendants)] | ||||
* - time in mempool | * - time in mempool | ||||
* - mining score (feerate modified by any fee deltas from | |||||
* PrioritiseTransaction) | |||||
* | * | ||||
* Note: the term "descendant" refers to in-mempool transactions that depend on | * Note: the term "descendant" refers to in-mempool transactions that depend on | ||||
* this one, while "ancestor" refers to in-mempool transactions that a given | * this one, while "ancestor" refers to in-mempool transactions that a given | ||||
* transaction depends on. | * transaction depends on. | ||||
* | * | ||||
* In order for the feerate sort to remain correct, we must update transactions | * In order for the feerate sort to remain correct, we must update transactions | ||||
* in the mempool when new descendants arrive. To facilitate this, we track the | * in the mempool when new descendants arrive. To facilitate this, we track the | ||||
* set of in-mempool direct parents and direct children in mapLinks. Within each | * set of in-mempool direct parents and direct children in mapLinks. Within each | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | typedef boost::multi_index_container< | ||||
boost::multi_index::tag<descendant_score>, | boost::multi_index::tag<descendant_score>, | ||||
boost::multi_index::identity<CTxMemPoolEntry>, | boost::multi_index::identity<CTxMemPoolEntry>, | ||||
CompareTxMemPoolEntryByDescendantScore>, | CompareTxMemPoolEntryByDescendantScore>, | ||||
// sorted by entry time | // sorted by entry time | ||||
boost::multi_index::ordered_non_unique< | boost::multi_index::ordered_non_unique< | ||||
boost::multi_index::tag<entry_time>, | boost::multi_index::tag<entry_time>, | ||||
boost::multi_index::identity<CTxMemPoolEntry>, | boost::multi_index::identity<CTxMemPoolEntry>, | ||||
CompareTxMemPoolEntryByEntryTime>, | CompareTxMemPoolEntryByEntryTime>, | ||||
// sorted by score (for mining prioritization) | |||||
boost::multi_index::ordered_unique< | |||||
boost::multi_index::tag<mining_score>, | |||||
boost::multi_index::identity<CTxMemPoolEntry>, | |||||
CompareTxMemPoolEntryByScore>, | |||||
// sorted by fee rate with ancestors | // sorted by fee rate with ancestors | ||||
boost::multi_index::ordered_non_unique< | boost::multi_index::ordered_non_unique< | ||||
boost::multi_index::tag<ancestor_score>, | boost::multi_index::tag<ancestor_score>, | ||||
boost::multi_index::identity<CTxMemPoolEntry>, | boost::multi_index::identity<CTxMemPoolEntry>, | ||||
CompareTxMemPoolEntryByAncestorFee>>> | CompareTxMemPoolEntryByAncestorFee>>> | ||||
indexed_transaction_set; | indexed_transaction_set; | ||||
mutable CCriticalSection cs; | mutable CCriticalSection cs; | ||||
▲ Show 20 Lines • Show All 421 Lines • Show Last 20 Lines |