![]() |
Bitcoin Core 32.99.0
P2P Digital Currency
|
Data structure storing a fee and size. More...
#include <feefrac.h>
Public Member Functions | |
| constexpr | FeeFrac () noexcept |
| Construct an IsEmpty() FeeFrac. | |
| constexpr | FeeFrac (int64_t f, int32_t s) noexcept |
| Construct a FeeFrac with specified fee and size. | |
| constexpr | FeeFrac (const FeeFrac &) noexcept=default |
| constexpr FeeFrac & | operator= (const FeeFrac &) noexcept=default |
| bool | IsEmpty () const noexcept |
| Check if this is empty (size and fee are 0). | |
| void | operator+= (const FeeFrac &other) noexcept |
| Add fee and size of another FeeFrac to this one. | |
| void | operator-= (const FeeFrac &other) noexcept |
| Subtract fee and size of another FeeFrac from this one. | |
| template<bool RoundDown> | |
| int64_t | EvaluateFee (int32_t at_size) const noexcept |
Compute the fee for a given size at_size using this object's feerate. | |
| int64_t | EvaluateFeeDown (int32_t at_size) const noexcept |
Compute the fee for a given size at_size using this object's feerate, rounding down. | |
| int64_t | EvaluateFeeUp (int32_t at_size) const noexcept |
Compute the fee for a given size at_size using this object's feerate, rounding up. | |
Static Public Member Functions | |
| static std::pair< int64_t, uint32_t > | MulFallback (int64_t a, int32_t b) noexcept |
| Helper function for 32*64 signed multiplication, returning an unspecified but totally ordered type. | |
| static int64_t | DivFallback (std::pair< int64_t, uint32_t > n, int32_t d, bool round_down) noexcept |
| Helper function for 96/32 signed division, rounding towards negative infinity (if round_down) or positive infinity (if !round_down). | |
Public Attributes | |
| int64_t | fee |
| int32_t | size |
Static Public Attributes | |
| static constexpr auto | Mul = MulFallback |
| static constexpr auto | Div = DivFallback |
Friends | |
| FeeFrac | operator+ (const FeeFrac &a, const FeeFrac &b) noexcept |
| Sum fee and size. | |
| FeeFrac | operator- (const FeeFrac &a, const FeeFrac &b) noexcept |
| Subtract both fee and size. | |
| bool | operator== (const FeeFrac &a, const FeeFrac &b) noexcept |
| Check if two FeeFrac objects are equal (both same fee and same size). | |
| void | swap (FeeFrac &a, FeeFrac &b) noexcept |
| Swap two FeeFracs. | |
Data structure storing a fee and size.
The size of a FeeFrac cannot be zero unless the fee is also zero.
|
inlineconstexprnoexcept |
|
inlinestaticnoexcept |
Helper function for 96/32 signed division, rounding towards negative infinity (if round_down) or positive infinity (if !round_down).
This is a fallback version, separate so that it can be tested on platforms where it isn't actually needed.
The exact behavior with negative n does not really matter, but this implementation chooses to be consistent for testability reasons.
The result must fit in an int64_t, and d must be strictly positive.
Definition at line 40 of file feefrac.h.
Compute the fee for a given size at_size using this object's feerate.
This effectively corresponds to evaluating (this->fee * at_size) / this->size, with the result rounded towards negative infinity (if RoundDown) or towards positive infinity (if !RoundDown).
Requires this->size > 0, at_size >= 0, and that the correct result fits in a int64_t. This is guaranteed to be the case when 0 <= at_size <= this->size.
Definition at line 154 of file feefrac.h.
|
inlinenoexcept |
|
inlinestaticnoexcept |
Helper function for 32*64 signed multiplication, returning an unspecified but totally ordered type.
This is a fallback version, separate so it can be tested on platforms where it isn't actually needed.
Definition at line 25 of file feefrac.h.
|
staticconstexpr |
|
staticconstexpr |