@@ -206,31 +206,36 @@ class CompareTxMemPoolEntryByDescendantScore
206206public:
207207 bool operator ()(const CTxMemPoolEntry& a, const CTxMemPoolEntry& b) const
208208 {
209- bool fUseADescendants = UseDescendantScore (a);
210- bool fUseBDescendants = UseDescendantScore (b);
209+ double a_mod_fee, a_size, b_mod_fee, b_size;
211210
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);
217213
218214 // 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 ;
221217
222218 if (f1 == f2) {
223219 return a.GetTime () >= b.GetTime ();
224220 }
225221 return f1 < f2;
226222 }
227223
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
230226 {
227+ // Compare feerate with descendants to feerate of the transaction, and
228+ // return the fee/size for the max.
231229 double f1 = (double )a.GetModifiedFee () * a.GetSizeWithDescendants ();
232230 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+ }
234239 }
235240};
236241
0 commit comments