Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | |||||
private: | private: | ||||
const LockPoints &lp; | const LockPoints &lp; | ||||
}; | }; | ||||
// extracts a TxMemPoolEntry's transaction hash | // extracts a TxMemPoolEntry's transaction hash | ||||
struct mempoolentry_txid { | struct mempoolentry_txid { | ||||
typedef uint256 result_type; | typedef uint256 result_type; | ||||
result_type operator()(const CTxMemPoolEntry &entry) const { | result_type operator()(const CTxMemPoolEntry &entry) const { | ||||
return entry.GetTx().GetId(); | return entry.GetTx().GetHash(); | ||||
} | } | ||||
}; | }; | ||||
/** \class CompareTxMemPoolEntryByDescendantScore | /** \class CompareTxMemPoolEntryByDescendantScore | ||||
* | * | ||||
* Sort an entry by max(score/size of entry's tx, score/size with all | * Sort an entry by max(score/size of entry's tx, score/size with all | ||||
* descendants). | * descendants). | ||||
*/ | */ | ||||
Show All 40 Lines | |||||
* Sort by score of entry ((fee+delta)/size) in descending order | * Sort by score of entry ((fee+delta)/size) in descending order | ||||
*/ | */ | ||||
class CompareTxMemPoolEntryByScore { | class CompareTxMemPoolEntryByScore { | ||||
public: | public: | ||||
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) { | bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) { | ||||
double f1 = double(b.GetTxSize() * a.GetModifiedFee().GetSatoshis()); | double f1 = double(b.GetTxSize() * a.GetModifiedFee().GetSatoshis()); | ||||
double f2 = double(a.GetTxSize() * b.GetModifiedFee().GetSatoshis()); | double f2 = double(a.GetTxSize() * b.GetModifiedFee().GetSatoshis()); | ||||
if (f1 == f2) { | if (f1 == f2) { | ||||
return b.GetTx().GetId() < a.GetTx().GetId(); | return b.GetTx().GetHash() < a.GetTx().GetHash(); | ||||
} | } | ||||
return f1 > f2; | return f1 > f2; | ||||
} | } | ||||
}; | }; | ||||
class CompareTxMemPoolEntryByEntryTime { | class CompareTxMemPoolEntryByEntryTime { | ||||
public: | public: | ||||
bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) { | bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) { | ||||
Show All 10 Lines | bool operator()(const CTxMemPoolEntry &a, const CTxMemPoolEntry &b) { | ||||
double bFees = double(b.GetModFeesWithAncestors().GetSatoshis()); | double bFees = double(b.GetModFeesWithAncestors().GetSatoshis()); | ||||
double bSize = b.GetSizeWithAncestors(); | double bSize = b.GetSizeWithAncestors(); | ||||
// Avoid division by rewriting (a/b > c/d) as (a*d > c*b). | // Avoid division by rewriting (a/b > c/d) as (a*d > c*b). | ||||
double f1 = aFees * bSize; | double f1 = aFees * bSize; | ||||
double f2 = aSize * bFees; | double f2 = aSize * bFees; | ||||
if (f1 == f2) { | if (f1 == f2) { | ||||
return a.GetTx().GetId() < b.GetTx().GetId(); | return a.GetTx().GetHash() < b.GetTx().GetHash(); | ||||
} | } | ||||
return f1 > f2; | return f1 > f2; | ||||
} | } | ||||
}; | }; | ||||
// Multi_index tag names | // Multi_index tag names | ||||
struct descendant_score {}; | struct descendant_score {}; | ||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | public: | ||||
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; | ||||
//!< All tx hashes/entries in mapTx, in random order | //!< All tx hashes/entries in mapTx, in random order | ||||
std::vector<std::pair<uint256, txiter>> vTxHashes; | std::vector<std::pair<uint256, txiter>> vTxHashes; | ||||
struct CompareIteratorByHash { | struct CompareIteratorByHash { | ||||
bool operator()(const txiter &a, const txiter &b) const { | bool operator()(const txiter &a, const txiter &b) const { | ||||
return a->GetTx().GetId() < b->GetTx().GetId(); | return a->GetTx().GetHash() < b->GetTx().GetHash(); | ||||
} | } | ||||
}; | }; | ||||
typedef std::set<txiter, CompareIteratorByHash> setEntries; | typedef std::set<txiter, CompareIteratorByHash> setEntries; | ||||
const setEntries &GetMemPoolParents(txiter entry) const; | const setEntries &GetMemPoolParents(txiter entry) const; | ||||
const setEntries &GetMemPoolChildren(txiter entry) const; | const setEntries &GetMemPoolChildren(txiter entry) const; | ||||
private: | private: | ||||
▲ Show 20 Lines • Show All 280 Lines • Show Last 20 Lines |