Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee, | ||||
mod_fee = a.GetModifiedFee() / SATOSHI; | mod_fee = a.GetModifiedFee() / SATOSHI; | ||||
size = a.GetTxSize(); | size = a.GetTxSize(); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
/** \class CompareTxMemPoolEntryByScore | /** \class CompareTxMemPoolEntryByScore | ||||
* | * | ||||
* Sort by score of entry ((fee+delta)/size) in descending order | * Sort by feerate of entry (fee/size) in descending order | ||||
* This is only used for transaction relay, so we use GetFee() | |||||
* instead of GetModifiedFee() to avoid leaking prioritization | |||||
* information via the sort order. | |||||
*/ | */ | ||||
class CompareTxMemPoolEntryByScore { | class CompareTxMemPoolEntryByScore { | ||||
public: | public: | ||||
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const { | bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const { | ||||
double f1 = b.GetTxSize() * (a.GetModifiedFee() / SATOSHI); | double f1 = b.GetTxSize() * (a.GetFee() / SATOSHI); | ||||
double f2 = a.GetTxSize() * (b.GetModifiedFee() / SATOSHI); | double f2 = a.GetTxSize() * (b.GetFee() / SATOSHI); | ||||
if (f1 == f2) { | if (f1 == f2) { | ||||
return b.GetTx().GetId() < a.GetTx().GetId(); | return b.GetTx().GetId() < a.GetTx().GetId(); | ||||
} | } | ||||
return f1 > f2; | return f1 > f2; | ||||
} | } | ||||
}; | }; | ||||
class CompareTxMemPoolEntryByEntryTime { | class CompareTxMemPoolEntryByEntryTime { | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | |||||
* the pool where the new transaction does not meet the Replace-By-Fee | * the pool where the new transaction does not meet the Replace-By-Fee | ||||
* requirements as defined in BIP 125. | * requirements as defined in BIP 125. | ||||
* - 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)] | * - descendant feerate [we use max(feerate of tx, feerate of tx with all | ||||
* descendants)] | |||||
* - time in mempool | * - time in mempool | ||||
* - ancestor feerate [we use min(feerate of tx, feerate of tx with all | |||||
* unconfirmed ancestors)] | |||||
* | * | ||||
* 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 511 Lines • Show Last 20 Lines |