Coverage Report

Created: 2026-09-01 13:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/bitcoin/src/util/feefrac.h
Line
Count
Source
1
// Copyright (c) The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_UTIL_FEEFRAC_H
6
#define BITCOIN_UTIL_FEEFRAC_H
7
8
#include <util/check.h>
9
#include <util/overflow.h>
10
11
#include <compare>
12
#include <concepts>
13
#include <cstdint>
14
#include <span>
15
#include <utility>
16
17
/** Data structure storing a fee and size.
18
 *
19
 * The size of a FeeFrac cannot be zero unless the fee is also zero.
20
 */
21
struct FeeFrac
22
{
23
    /** Helper function for 32*64 signed multiplication, returning an unspecified but totally
24
     *  ordered type. This is a fallback version, separate so it can be tested on platforms where
25
     *  it isn't actually needed. */
26
    static inline std::pair<int64_t, uint32_t> MulFallback(int64_t a, int32_t b) noexcept
27
82
    {
28
82
        int64_t low = int64_t{static_cast<uint32_t>(a)} * b;
29
82
        int64_t high = (a >> 32) * b;
30
82
        return {high + (low >> 32), static_cast<uint32_t>(low)};
31
82
    }
32
33
    /** Helper function for 96/32 signed division, rounding towards negative infinity (if
34
     *  round_down) or positive infinity (if !round_down). This is a fallback version, separate so
35
     *  that it can be tested on platforms where it isn't actually needed.
36
     *
37
     * The exact behavior with negative n does not really matter, but this implementation chooses
38
     * to be consistent for testability reasons.
39
     *
40
     * The result must fit in an int64_t, and d must be strictly positive. */
41
    static inline int64_t DivFallback(std::pair<int64_t, uint32_t> n, int32_t d, bool round_down) noexcept
42
52
    {
43
52
        Assume(d > 0);
44
        // Compute quot_high = n.first / d, so the result becomes
45
        // (n.second + (n.first - quot_high * d) * 2**32) / d + (quot_high * 2**32), or
46
        // (n.second + (n.first % d) * 2**32) / d + (quot_high * 2**32).
47
52
        int64_t quot_high = n.first / d;
48
        // Evaluate the parenthesized expression above, so the result becomes
49
        // n_low / d + (quot_high * 2**32)
50
52
        int64_t n_low = ((n.first % d) << 32) + n.second;
51
        // Evaluate the division so the result becomes quot_low + quot_high * 2**32. It is possible
52
        // that the / operator here rounds in the wrong direction (if n_low is not a multiple of
53
        // size, and is (if round_down) negative, or (if !round_down) positive). If so, make a
54
        // correction.
55
52
        int64_t quot_low = n_low / d;
56
52
        int32_t mod_low = n_low % d;
57
52
        quot_low += (mod_low > 0) - (mod_low && round_down);
  Branch (57:38): [True: 25, False: 27]
  Branch (57:49): [True: 6, False: 19]
58
        // Combine and return the result
59
52
        return (quot_high << 32) + quot_low;
60
52
    }
61
62
#ifdef __SIZEOF_INT128__
63
    /** Helper function for 32*64 signed multiplication, returning an unspecified but totally
64
     *  ordered type. This is a version relying on __int128. */
65
    static inline __int128 Mul(int64_t a, int32_t b) noexcept
66
785M
    {
67
785M
        return __int128{a} * b;
68
785M
    }
69
70
    /** Helper function for 96/32 signed division, rounding towards negative infinity (if
71
     *  round_down), or towards positive infinity (if !round_down). This is a
72
     *  version relying on __int128.
73
     *
74
     * The result must fit in an int64_t, and d must be strictly positive. */
75
    static inline int64_t Div(__int128 n, int32_t d, bool round_down) noexcept
76
83.0k
    {
77
83.0k
        Assume(d > 0);
78
        // Compute the division.
79
83.0k
        int64_t quot = n / d;
80
83.0k
        int32_t mod = n % d;
81
        // Correct result if the / operator above rounded in the wrong direction.
82
83.0k
        return quot + ((mod > 0) - (mod && round_down));
  Branch (82:37): [True: 58.2k, False: 24.8k]
  Branch (82:44): [True: 9.49k, False: 48.7k]
83
83.0k
    }
84
#else
85
    static constexpr auto Mul = MulFallback;
86
    static constexpr auto Div = DivFallback;
87
#endif
88
89
    int64_t fee;
90
    int32_t size;
91
92
    /** Construct an IsEmpty() FeeFrac. */
93
48.4M
    constexpr inline FeeFrac() noexcept : fee{0}, size{0} {}
94
95
    /** Construct a FeeFrac with specified fee and size. */
96
95.1M
    constexpr inline FeeFrac(int64_t f, int32_t s) noexcept : fee{f}, size{s} {}
97
98
    constexpr inline FeeFrac(const FeeFrac&) noexcept = default;
99
    constexpr inline FeeFrac& operator=(const FeeFrac&) noexcept = default;
100
101
    /** Check if this is empty (size and fee are 0). */
102
85.2M
    bool inline IsEmpty() const noexcept {
103
85.2M
        return size == 0;
104
85.2M
    }
105
106
    /** Add fee and size of another FeeFrac to this one. */
107
    void inline operator+=(const FeeFrac& other) noexcept
108
340M
    {
109
340M
        fee += other.fee;
110
340M
        size += other.size;
111
340M
    }
112
113
    /** Subtract fee and size of another FeeFrac from this one. */
114
    void inline operator-=(const FeeFrac& other) noexcept
115
4.80M
    {
116
4.80M
        fee -= other.fee;
117
4.80M
        size -= other.size;
118
4.80M
    }
119
120
    /** Sum fee and size. */
121
    friend inline FeeFrac operator+(const FeeFrac& a, const FeeFrac& b) noexcept
122
19.0M
    {
123
19.0M
        return {a.fee + b.fee, a.size + b.size};
124
19.0M
    }
125
126
    /** Subtract both fee and size. */
127
    friend inline FeeFrac operator-(const FeeFrac& a, const FeeFrac& b) noexcept
128
8.85M
    {
129
8.85M
        return {a.fee - b.fee, a.size - b.size};
130
8.85M
    }
131
132
    /** Check if two FeeFrac objects are equal (both same fee and same size). */
133
    friend inline bool operator==(const FeeFrac& a, const FeeFrac& b) noexcept
134
17.6M
    {
135
17.6M
        return a.fee == b.fee && a.size == b.size;
  Branch (135:16): [True: 9.98M, False: 7.67M]
  Branch (135:34): [True: 9.53M, False: 446k]
136
17.6M
    }
137
138
    /** Swap two FeeFracs. */
139
    friend inline void swap(FeeFrac& a, FeeFrac& b) noexcept
140
7.85M
    {
141
7.85M
        std::swap(a.fee, b.fee);
142
7.85M
        std::swap(a.size, b.size);
143
7.85M
    }
144
145
    /** Compute the fee for a given size `at_size` using this object's feerate.
146
     *
147
     * This effectively corresponds to evaluating (this->fee * at_size) / this->size, with the
148
     * result rounded towards negative infinity (if RoundDown) or towards positive infinity
149
     * (if !RoundDown).
150
     *
151
     * Requires this->size > 0, at_size >= 0, and that the correct result fits in a int64_t. This
152
     * is guaranteed to be the case when 0 <= at_size <= this->size.
153
     */
154
    template<bool RoundDown>
155
    int64_t EvaluateFee(int32_t at_size) const noexcept
156
82.9M
    {
157
82.9M
        Assume(size > 0);
158
82.9M
        Assume(at_size >= 0);
159
82.9M
        if (fee >= 0 && fee < 0x200000000) [[likely]] {
  Branch (159:13): [True: 860k, False: 1.49k]
  Branch (159:25): [True: 827k, False: 32.0k]
  Branch (159:13): [True: 82.0M, False: 14]
  Branch (159:25): [True: 82.0M, False: 49.4k]
160
            // Common case where (this->fee * at_size) is guaranteed to fit in a uint64_t.
161
82.8M
            if constexpr (RoundDown) {
162
827k
                return (uint64_t(fee) * at_size) / uint32_t(size);
163
82.0M
            } else {
164
82.0M
                return CeilDiv(uint64_t(fee) * at_size, uint32_t(size));
165
82.0M
            }
166
82.8M
        } else {
167
            // Otherwise, use Mul and Div.
168
83.0k
            return Div(Mul(fee, at_size), size, RoundDown);
169
83.0k
        }
170
82.9M
    }
_ZNK7FeeFrac11EvaluateFeeILb1EEEli
Line
Count
Source
156
861k
    {
157
861k
        Assume(size > 0);
158
861k
        Assume(at_size >= 0);
159
861k
        if (fee >= 0 && fee < 0x200000000) [[likely]] {
  Branch (159:13): [True: 860k, False: 1.49k]
  Branch (159:25): [True: 827k, False: 32.0k]
160
            // Common case where (this->fee * at_size) is guaranteed to fit in a uint64_t.
161
827k
            if constexpr (RoundDown) {
162
827k
                return (uint64_t(fee) * at_size) / uint32_t(size);
163
            } else {
164
                return CeilDiv(uint64_t(fee) * at_size, uint32_t(size));
165
            }
166
827k
        } else {
167
            // Otherwise, use Mul and Div.
168
33.5k
            return Div(Mul(fee, at_size), size, RoundDown);
169
33.5k
        }
170
861k
    }
_ZNK7FeeFrac11EvaluateFeeILb0EEEli
Line
Count
Source
156
82.0M
    {
157
82.0M
        Assume(size > 0);
158
82.0M
        Assume(at_size >= 0);
159
82.0M
        if (fee >= 0 && fee < 0x200000000) [[likely]] {
  Branch (159:13): [True: 82.0M, False: 14]
  Branch (159:25): [True: 82.0M, False: 49.4k]
160
            // Common case where (this->fee * at_size) is guaranteed to fit in a uint64_t.
161
            if constexpr (RoundDown) {
162
                return (uint64_t(fee) * at_size) / uint32_t(size);
163
82.0M
            } else {
164
82.0M
                return CeilDiv(uint64_t(fee) * at_size, uint32_t(size));
165
82.0M
            }
166
82.0M
        } else {
167
            // Otherwise, use Mul and Div.
168
49.4k
            return Div(Mul(fee, at_size), size, RoundDown);
169
49.4k
        }
170
82.0M
    }
171
172
public:
173
    /** Compute the fee for a given size `at_size` using this object's feerate, rounding down. */
174
861k
    int64_t EvaluateFeeDown(int32_t at_size) const noexcept { return EvaluateFee<true>(at_size); }
175
    /** Compute the fee for a given size `at_size` using this object's feerate, rounding up. */
176
82.0M
    int64_t EvaluateFeeUp(int32_t at_size) const noexcept { return EvaluateFee<false>(at_size); }
177
};
178
179
/** Compare the feerate diagrams implied by the provided sorted chunks data.
180
 *
181
 * The implied diagram for each starts at (0, 0), then contains for each chunk the cumulative fee
182
 * and size up to that chunk, and then extends infinitely to the right with a horizontal line.
183
 *
184
 * The caller must guarantee that the sum of the FeeFracs in either of the chunks' data set do not
185
 * overflow (so sum fees < 2^63, and sum sizes < 2^31).
186
 */
187
std::partial_ordering CompareChunks(std::span<const FeeFrac> chunks0, std::span<const FeeFrac> chunks1);
188
189
/** Tagged wrapper around FeeFrac to avoid unit confusion. */
190
template<typename Tag>
191
struct FeePerUnit : public FeeFrac
192
{
193
    // Inherit FeeFrac constructors.
194
    using FeeFrac::FeeFrac;
195
196
    /** Convert a FeeFrac to a FeePerUnit. */
197
    static FeePerUnit FromFeeFrac(const FeeFrac& feefrac) noexcept
198
7.11M
    {
199
7.11M
        return {feefrac.fee, feefrac.size};
200
7.11M
    }
201
};
202
203
// FeePerUnit instance for satoshi / vbyte.
204
struct VSizeTag {};
205
using FeePerVSize = FeePerUnit<VSizeTag>;
206
207
// FeePerUnit instance for satoshi / WU.
208
struct WeightTag {};
209
using FeePerWeight = FeePerUnit<WeightTag>;
210
211
/** Wrapper around FeeFrac & derived types, which adds a feerate-based ordering which treats
212
 *  equal-feerate but distinct-size FeeFracs as equals.
213
 *
214
 *  This is not included inside FeeFrac itself, because it is not a total ordering (as would be
215
 *  expected for built-in comparison operators).
216
 */
217
template<std::derived_from<FeeFrac> T>
218
class ByRatio
219
{
220
    const T& m_feefrac;
221
222
public:
223
623M
    constexpr ByRatio(const T& feefrac) noexcept : m_feefrac{feefrac} {}
_ZN7ByRatioI7FeeFracEC2ERKS0_
Line
Count
Source
223
164M
    constexpr ByRatio(const T& feefrac) noexcept : m_feefrac{feefrac} {}
_ZN7ByRatioI10FeePerUnitI8VSizeTagEEC2ERKS2_
Line
Count
Source
223
1.26M
    constexpr ByRatio(const T& feefrac) noexcept : m_feefrac{feefrac} {}
_ZN7ByRatioI10FeePerUnitI9WeightTagEEC2ERKS2_
Line
Count
Source
223
458M
    constexpr ByRatio(const T& feefrac) noexcept : m_feefrac{feefrac} {}
224
225
    friend bool operator==(const ByRatio& a, const ByRatio& b) noexcept
226
117k
    {
227
117k
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
228
117k
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
229
117k
        return cross_a == cross_b;
230
117k
    }
_ZeqRK7ByRatioI10FeePerUnitI8VSizeTagEES5_
Line
Count
Source
226
2.37k
    {
227
2.37k
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
228
2.37k
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
229
2.37k
        return cross_a == cross_b;
230
2.37k
    }
_ZeqRK7ByRatioI7FeeFracES3_
Line
Count
Source
226
115k
    {
227
115k
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
228
115k
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
229
115k
        return cross_a == cross_b;
230
115k
    }
231
232
    // Note that we can use std::strong_ordering here, because even though FeeFrac{1,2} and
233
    // FeeFrac{2,4} are distinct as FeeFracs, they are indistinguishable from ByRatio's perspective
234
    // (operator== also treats them as equal).
235
    friend std::strong_ordering operator<=>(const ByRatio& a, const ByRatio& b) noexcept
236
261M
    {
237
261M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
238
261M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
239
261M
        return cross_a <=> cross_b;
240
261M
    }
_ZssRK7ByRatioI10FeePerUnitI8VSizeTagEES5_
Line
Count
Source
236
565k
    {
237
565k
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
238
565k
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
239
565k
        return cross_a <=> cross_b;
240
565k
    }
_ZssRK7ByRatioI7FeeFracES3_
Line
Count
Source
236
32.3M
    {
237
32.3M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
238
32.3M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
239
32.3M
        return cross_a <=> cross_b;
240
32.3M
    }
_ZssRK7ByRatioI10FeePerUnitI9WeightTagEES5_
Line
Count
Source
236
228M
    {
237
228M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
238
228M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
239
228M
        return cross_a <=> cross_b;
240
228M
    }
241
242
    // Specialized versions for efficiency. GCC 15+ and Clang 11+ produce operator<=>-derived
243
    // versions that are equally efficient as this at -O2, but earlier versions do not.
244
    friend bool operator<(const ByRatio& a, const ByRatio& b) noexcept
245
9.53M
    {
246
9.53M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
247
9.53M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
248
9.53M
        return cross_a < cross_b;
249
9.53M
    }
_ZltRK7ByRatioI7FeeFracES3_
Line
Count
Source
245
9.47M
    {
246
9.47M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
247
9.47M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
248
9.47M
        return cross_a < cross_b;
249
9.47M
    }
_ZltRK7ByRatioI10FeePerUnitI8VSizeTagEES5_
Line
Count
Source
245
63.0k
    {
246
63.0k
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
247
63.0k
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
248
63.0k
        return cross_a < cross_b;
249
63.0k
    }
250
    friend bool operator>(const ByRatio& a, const ByRatio& b) noexcept
251
38.0M
    {
252
38.0M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
253
38.0M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
254
38.0M
        return cross_a > cross_b;
255
38.0M
    }
_ZgtRK7ByRatioI7FeeFracES3_
Line
Count
Source
251
38.0M
    {
252
38.0M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
253
38.0M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
254
38.0M
        return cross_a > cross_b;
255
38.0M
    }
Unexecuted instantiation: _ZgtRK7ByRatioI10FeePerUnitI8VSizeTagEES5_
256
    friend bool operator<=(const ByRatio& a, const ByRatio& b) noexcept
257
985k
    {
258
985k
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
259
985k
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
260
985k
        return cross_a <= cross_b;
261
985k
    }
_ZleRK7ByRatioI7FeeFracES3_
Line
Count
Source
257
902k
    {
258
902k
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
259
902k
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
260
902k
        return cross_a <= cross_b;
261
902k
    }
_ZleRK7ByRatioI10FeePerUnitI9WeightTagEES5_
Line
Count
Source
257
83.3k
    {
258
83.3k
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
259
83.3k
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
260
83.3k
        return cross_a <= cross_b;
261
83.3k
    }
262
    friend bool operator>=(const ByRatio& a, const ByRatio& b) noexcept
263
1.44M
    {
264
1.44M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
265
1.44M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
266
1.44M
        return cross_a >= cross_b;
267
1.44M
    }
_ZgeRK7ByRatioI7FeeFracES3_
Line
Count
Source
263
1.36M
    {
264
1.36M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
265
1.36M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
266
1.36M
        return cross_a >= cross_b;
267
1.36M
    }
_ZgeRK7ByRatioI10FeePerUnitI9WeightTagEES5_
Line
Count
Source
263
81.5k
    {
264
81.5k
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
265
81.5k
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
266
81.5k
        return cross_a >= cross_b;
267
81.5k
    }
268
};
269
270
/** Wrapper around FeeFrac & derived types, which adds a total ordering which first sorts by feerate
271
 *  and then by reversed size (i.e., larger sizes come first).
272
 *
273
 *  This is not included inside FeeFrac itself, because it is not the most natural behavior, so it
274
 *  is better to make code using it invoke this explicitly.
275
 *
276
 *  The empty FeeFrac (fee and size both 0) sorts last. So for example, the following FeeFracs are
277
 *  in sorted order:
278
 *
279
 *   - fee=0 size=1 (feerate 0)
280
 *   - fee=1 size=2 (feerate 0.5)
281
 *   - fee=2 size=3 (feerate 0.667...)
282
 *   - fee=2 size=2 (feerate 1)
283
 *   - fee=1 size=1 (feerate 1)
284
 *   - fee=3 size=2 (feerate 1.5)
285
 *   - fee=2 size=1 (feerate 2)
286
 *   - fee=0 size=0 (undefined feerate)
287
 */
288
template<std::derived_from<FeeFrac> T>
289
class ByRatioNegSize
290
{
291
    const T& m_feefrac;
292
293
public:
294
161M
    constexpr ByRatioNegSize(const T& feefrac) noexcept : m_feefrac{feefrac} {}
_ZN14ByRatioNegSizeI7FeeFracEC2ERKS0_
Line
Count
Source
294
158M
    constexpr ByRatioNegSize(const T& feefrac) noexcept : m_feefrac{feefrac} {}
_ZN14ByRatioNegSizeI10FeePerUnitI9WeightTagEEC2ERKS2_
Line
Count
Source
294
2.86M
    constexpr ByRatioNegSize(const T& feefrac) noexcept : m_feefrac{feefrac} {}
295
296
    friend bool operator==(const ByRatioNegSize& a, const ByRatioNegSize& b) noexcept
297
50
    {
298
50
        return a.m_feefrac == b.m_feefrac;
299
50
    }
300
301
    friend std::strong_ordering operator<=>(const ByRatioNegSize& a, const ByRatioNegSize& b) noexcept
302
80.9M
    {
303
80.9M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
304
80.9M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
305
80.9M
        auto cmp = cross_a <=> cross_b;
306
80.9M
        if (cmp != 0) return cmp;
  Branch (306:13): [True: 46.2M, False: 33.2M]
  Branch (306:13): [True: 638k, False: 793k]
307
34.0M
        return b.m_feefrac.size <=> a.m_feefrac.size;
308
80.9M
    }
_ZssRK14ByRatioNegSizeI7FeeFracES3_
Line
Count
Source
302
79.4M
    {
303
79.4M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
304
79.4M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
305
79.4M
        auto cmp = cross_a <=> cross_b;
306
79.4M
        if (cmp != 0) return cmp;
  Branch (306:13): [True: 46.2M, False: 33.2M]
307
33.2M
        return b.m_feefrac.size <=> a.m_feefrac.size;
308
79.4M
    }
_ZssRK14ByRatioNegSizeI10FeePerUnitI9WeightTagEES5_
Line
Count
Source
302
1.43M
    {
303
1.43M
        auto cross_a = T::Mul(a.m_feefrac.fee, b.m_feefrac.size);
304
1.43M
        auto cross_b = T::Mul(b.m_feefrac.fee, a.m_feefrac.size);
305
1.43M
        auto cmp = cross_a <=> cross_b;
306
1.43M
        if (cmp != 0) return cmp;
  Branch (306:13): [True: 638k, False: 793k]
307
793k
        return b.m_feefrac.size <=> a.m_feefrac.size;
308
1.43M
    }
309
310
    // Support conversion back to underlying FeeFrac, which allows using std::max().
311
22.1M
    operator const T&() const noexcept { return m_feefrac; }
312
};
313
314
#endif // BITCOIN_UTIL_FEEFRAC_H