|
|
@ -266,27 +266,46 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** \class CompareTxMemPoolEntryByAncestorScore
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Sort an entry by min(score/size of entry's tx, score/size with all ancestors).
|
|
|
|
|
|
|
|
*/
|
|
|
|
class CompareTxMemPoolEntryByAncestorFee
|
|
|
|
class CompareTxMemPoolEntryByAncestorFee
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
|
|
|
|
bool operator()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
double aFees = a.GetModFeesWithAncestors();
|
|
|
|
double a_mod_fee, a_size, b_mod_fee, b_size;
|
|
|
|
double aSize = a.GetSizeWithAncestors();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double bFees = b.GetModFeesWithAncestors();
|
|
|
|
GetModFeeAndSize(a, a_mod_fee, a_size);
|
|
|
|
double bSize = b.GetSizeWithAncestors();
|
|
|
|
GetModFeeAndSize(b, b_mod_fee, b_size);
|
|
|
|
|
|
|
|
|
|
|
|
// 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 = a_mod_fee * b_size;
|
|
|
|
double f2 = aSize * bFees;
|
|
|
|
double f2 = a_size * b_mod_fee;
|
|
|
|
|
|
|
|
|
|
|
|
if (f1 == f2) {
|
|
|
|
if (f1 == f2) {
|
|
|
|
return a.GetTx().GetHash() < b.GetTx().GetHash();
|
|
|
|
return a.GetTx().GetHash() < b.GetTx().GetHash();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return f1 > f2;
|
|
|
|
return f1 > f2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Return the fee/size we're using for sorting this entry.
|
|
|
|
|
|
|
|
void GetModFeeAndSize(const CTxMemPoolEntry &a, double &mod_fee, double &size) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Compare feerate with ancestors to feerate of the transaction, and
|
|
|
|
|
|
|
|
// return the fee/size for the min.
|
|
|
|
|
|
|
|
double f1 = (double)a.GetModifiedFee() * a.GetSizeWithAncestors();
|
|
|
|
|
|
|
|
double f2 = (double)a.GetModFeesWithAncestors() * a.GetTxSize();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (f1 > f2) {
|
|
|
|
|
|
|
|
mod_fee = a.GetModFeesWithAncestors();
|
|
|
|
|
|
|
|
size = a.GetSizeWithAncestors();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
mod_fee = a.GetModifiedFee();
|
|
|
|
|
|
|
|
size = a.GetTxSize();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Multi_index tag names
|
|
|
|
// Multi_index tag names
|
|
|
|