ByRatioNegSize

Wrapper around FeeFrac & derived types, which adds a total ordering which first sorts by feerate and then by reversed size (i.e., larger sizes come first).

Synopsis

Declared in <util/feefrac.h>

template<std::derived_from<FeeFrac> T>
class ByRatioNegSize;

Description

This is not included inside FeeFrac itself, because it is not the most natural behavior, so it is better to make code using it invoke this explicitly.

The empty FeeFrac (fee and size both 0) sorts last. So for example, the following FeeFracs are in sorted order:

  • fee=0 size=1 (feerate 0)

  • fee=1 size=2 (feerate 0.5)

  • fee=2 size=3 (feerate 0.667...)

  • fee=2 size=2 (feerate 1)

  • fee=1 size=1 (feerate 1)

  • fee=3 size=2 (feerate 1.5)

  • fee=2 size=1 (feerate 2)

  • fee=0 size=0 (undefined feerate)

Member Functions

NameDescription
ByRatioNegSize [constructor]Wrap a FeeFrac (or derived type) for feerate-then-reversed-size comparison.
operator T const& Convert back to the underlying FeeFrac, which allows using std::max().

Friends

NameDescription
operator<=>Order two wrapped FeeFracs by feerate, then by reversed size.
operator==Check whether two wrapped FeeFracs are equal (same fee and same size).