diff options
author | Murch <murch@murch.one> | 2022-02-09 15:41:53 -0500 |
---|---|---|
committer | Murch <murch@murch.one> | 2022-02-14 16:01:26 -0500 |
commit | e50a9be1540c769a99fcdc1f7a109a6bf1c7516b (patch) | |
tree | f1c00187b9337f6b99f864a761897f7ad5e74044 /src | |
parent | 5e8e0b3d7f6055e326bda61e60712b530e8920f0 (diff) |
Remove outdated comment on CFeeRate
This comment described how the constructor of CFeeRate was previously
indirectly used to parse fee rate arguments from RPCs. The command line
input was actually in sat/vB but due to the use of AmountFromValue() it
got converted to BTC/vB. In the constructor this could be rectified by
creating a CFeeRate from that given value (in BTC/vB) and COIN as the
transaction size, turning the input effectively to sat/vB. Since this
usage pattern was removed from the codebase some months ago, the comment
is now obsolete.
Also:
• Use vsize and vbyte instead of size and byte
Diffstat (limited to 'src')
-rw-r--r-- | src/policy/feerate.h | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/policy/feerate.h b/src/policy/feerate.h index 188a44b73d..50fd6fd11b 100644 --- a/src/policy/feerate.h +++ b/src/policy/feerate.h @@ -24,35 +24,40 @@ enum class FeeEstimateMode { }; /** - * Fee rate in satoshis per kilobyte: CAmount / kB + * Fee rate in satoshis per kilovirtualbyte: CAmount / kvB */ class CFeeRate { private: - CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes + /** Fee rate in sat/kvB (satoshis per 1000 virtualbytes) */ + CAmount nSatoshisPerK; public: - /** Fee rate of 0 satoshis per kB */ + /** Fee rate of 0 satoshis per kvB */ CFeeRate() : nSatoshisPerK(0) { } template<typename I> explicit CFeeRate(const I _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { // We've previously had bugs creep in from silent double->int conversion... static_assert(std::is_integral<I>::value, "CFeeRate should be used without floats"); } - /** Constructor for a fee rate in satoshis per kvB (sat/kvB). + + /** + * Construct a fee rate from a fee in satoshis and a vsize in vB. * - * Passing a num_bytes value of COIN (1e8) returns a fee rate in satoshis per vB (sat/vB), - * e.g. (nFeePaid * 1e8 / 1e3) == (nFeePaid / 1e5), - * where 1e5 is the ratio to convert from BTC/kvB to sat/vB. + * param@[in] nFeePaid The fee paid by a transaction, in satoshis + * param@[in] num_bytes The vsize of a transaction, in vbytes */ CFeeRate(const CAmount& nFeePaid, uint32_t num_bytes); + /** - * Return the fee in satoshis for the given size in bytes. - * If the calculated fee would have fractional satoshis, then the returned fee will always be rounded up to the nearest satoshi. + * Return the fee in satoshis for the given vsize in vbytes. + * If the calculated fee would have fractional satoshis, then the + * returned fee will always be rounded up to the nearest satoshi. */ CAmount GetFee(uint32_t num_bytes) const; + /** - * Return the fee in satoshis for a size of 1000 bytes + * Return the fee in satoshis for a vsize of 1000 vbytes */ CAmount GetFeePerK() const { return GetFee(1000); } friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; } |