Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 319 Lines • ▼ Show 20 Lines | |||||
class CompareTxMemPoolEntryByEntryTime { | class CompareTxMemPoolEntryByEntryTime { | ||||
public: | public: | ||||
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const { | bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const { | ||||
return a.GetTime() < b.GetTime(); | return a.GetTime() < b.GetTime(); | ||||
} | } | ||||
}; | }; | ||||
class CompareTxMemPoolEntryByAncestorFee { | |||||
public: | |||||
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) const { | |||||
double aFees = a.GetModFeesWithAncestors() / SATOSHI; | |||||
double aSize = a.GetSizeWithAncestors(); | |||||
double bFees = b.GetModFeesWithAncestors() / SATOSHI; | |||||
double bSize = b.GetSizeWithAncestors(); | |||||
// Avoid division by rewriting (a/b > c/d) as (a*d > c*b). | |||||
double f1 = aFees * bSize; | |||||
double f2 = aSize * bFees; | |||||
if (f1 == f2) { | |||||
return a.GetTx().GetId() < b.GetTx().GetId(); | |||||
} | |||||
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 mining_score {}; | ||||
struct ancestor_score {}; | |||||
struct txid_index {}; | struct txid_index {}; | ||||
struct insertion_order {}; | struct insertion_order {}; | ||||
/** | /** | ||||
* Information about a mempool transaction. | * Information about a mempool transaction. | ||||
*/ | */ | ||||
struct TxMempoolInfo { | struct TxMempoolInfo { | ||||
/** The transaction itself */ | /** The transaction itself */ | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | typedef boost::multi_index_container< | ||||
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) | // sorted by score (for mining prioritization) | ||||
boost::multi_index::ordered_unique< | boost::multi_index::ordered_unique< | ||||
boost::multi_index::tag<mining_score>, | boost::multi_index::tag<mining_score>, | ||||
boost::multi_index::identity<CTxMemPoolEntry>, | boost::multi_index::identity<CTxMemPoolEntry>, | ||||
CompareTxMemPoolEntryByScore>, | CompareTxMemPoolEntryByScore>, | ||||
// sorted by fee rate with ancestors | |||||
boost::multi_index::ordered_non_unique< | |||||
boost::multi_index::tag<ancestor_score>, | |||||
boost::multi_index::identity<CTxMemPoolEntry>, | |||||
CompareTxMemPoolEntryByAncestorFee>, | |||||
boost::multi_index::sequenced< | boost::multi_index::sequenced< | ||||
boost::multi_index::tag<insertion_order>>>> | boost::multi_index::tag<insertion_order>>>> | ||||
indexed_transaction_set; | indexed_transaction_set; | ||||
mutable CCriticalSection cs; | mutable CCriticalSection cs; | ||||
indexed_transaction_set mapTx; | indexed_transaction_set mapTx; | ||||
typedef indexed_transaction_set::nth_index<0>::type::iterator txiter; | typedef indexed_transaction_set::nth_index<0>::type::iterator txiter; | ||||
▲ Show 20 Lines • Show All 402 Lines • Show Last 20 Lines |