mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 21:52:53 +02:00
feefrac: drop comparison and operator{<<,>>} for sorted wrappers
Instead of having an unintuitive but total implicit sort order on
FeeFrac (first increasing feerate, then decreasing size), and separate
overloaded operator<< and operator>> for a weak ordering that only looks
at feerate, replace these with explicit wrapper classes which make the
behavior more explicit.
This allows for things like ByRatio{a} <= ByRatio{b}, instead of the
earlier !(a >> b). It also supports usage inside std::max and
std::greater, so one can use:
* std::max<ByRatioNegSize<FeeFrac>>(a, b)
* std::sort(v.begin(), v.end(), std::greater<ByRatioNegSize<FeeFrac>>{})
This commit is contained in:
committed by
Pieter Wuille
parent
3a8b4e89f6
commit
747da25360
@@ -184,12 +184,12 @@ struct AncestorFeerateComparator
|
||||
auto min_feerate = [](const MiniMinerMempoolEntry& e) -> FeeFrac {
|
||||
FeeFrac self_feerate(e.GetModifiedFee(), e.GetTxSize());
|
||||
FeeFrac ancestor_feerate(e.GetModFeesWithAncestors(), e.GetSizeWithAncestors());
|
||||
return std::min(ancestor_feerate, self_feerate);
|
||||
return std::min<ByRatioNegSize<FeeFrac>>(ancestor_feerate, self_feerate);
|
||||
};
|
||||
FeeFrac a_feerate{min_feerate(a->second)};
|
||||
FeeFrac b_feerate{min_feerate(b->second)};
|
||||
if (a_feerate != b_feerate) {
|
||||
return a_feerate > b_feerate;
|
||||
return ByRatioNegSize{a_feerate} > ByRatioNegSize{b_feerate};
|
||||
}
|
||||
// Use txid as tiebreaker for stable sorting
|
||||
return a->first < b->first;
|
||||
|
||||
Reference in New Issue
Block a user