@@ -206,31 +206,36 @@ class CompareTxMemPoolEntryByDescendantScore
206
206
public:
207
207
bool operator ()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
208
208
{
209
- bool fUseADescendants = UseDescendantScore (a);
210
- bool fUseBDescendants = UseDescendantScore (b);
209
+ double a_mod_fee, a_size, b_mod_fee, b_size;
211
210
212
- double aModFee = fUseADescendants ? a.GetModFeesWithDescendants () : a.GetModifiedFee ();
213
- double aSize = fUseADescendants ? a.GetSizeWithDescendants () : a.GetTxSize ();
214
-
215
- double bModFee = fUseBDescendants ? b.GetModFeesWithDescendants () : b.GetModifiedFee ();
216
- double bSize = fUseBDescendants ? b.GetSizeWithDescendants () : b.GetTxSize ();
211
+ GetModFeeAndSize (a, a_mod_fee, a_size);
212
+ GetModFeeAndSize (b, b_mod_fee, b_size);
217
213
218
214
// Avoid division by rewriting (a/b > c/d) as (a*d > c*b).
219
- double f1 = aModFee * bSize ;
220
- double f2 = aSize * bModFee ;
215
+ double f1 = a_mod_fee * b_size ;
216
+ double f2 = a_size * b_mod_fee ;
221
217
222
218
if (f1 == f2) {
223
219
return a.GetTime () >= b.GetTime ();
224
220
}
225
221
return f1 < f2;
226
222
}
227
223
228
- // Calculate which score to use for an entry (avoiding division) .
229
- bool UseDescendantScore (const CTxMemPoolEntry &a) const
224
+ // Return the fee/size we're using for sorting this entry .
225
+ void GetModFeeAndSize (const CTxMemPoolEntry &a, double &mod_fee, double &size ) const
230
226
{
227
+ // Compare feerate with descendants to feerate of the transaction, and
228
+ // return the fee/size for the max.
231
229
double f1 = (double )a.GetModifiedFee () * a.GetSizeWithDescendants ();
232
230
double f2 = (double )a.GetModFeesWithDescendants () * a.GetTxSize ();
233
- return f2 > f1;
231
+
232
+ if (f2 > f1) {
233
+ mod_fee = a.GetModFeesWithDescendants ();
234
+ size = a.GetSizeWithDescendants ();
235
+ } else {
236
+ mod_fee = a.GetModifiedFee ();
237
+ size = a.GetTxSize ();
238
+ }
234
239
}
235
240
};
236
241
0 commit comments