diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-05-24 11:11:55 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-05-24 11:14:23 +0200 |
commit | ce4a852475fc445be88685197ea48c19256e0401 (patch) | |
tree | fa543f1b6f2178aad66d6f387a4f79eaec3663df /src/policy/feerate.h | |
parent | 599000903e09e5ae3784d15ae078a2e1ed89ab12 (diff) | |
parent | fafd121026c4f1e25d498983e4f88c119516552b (diff) |
Merge bitcoin/bitcoin#21848: refactor: Make CFeeRate constructor architecture-independent
fafd121026c4f1e25d498983e4f88c119516552b refactor: Make CFeeRate constructor architecture-independent (MarcoFalke)
Pull request description:
Currently the constructor is architecture dependent. This is confusing for several reasons:
* It is impossible to create a transaction larger than the max value of `uint32_t`, so a 64-bit `size_t` is not needed
* Policy (and consensus) code should be arch-independent
* The current code will print spurious compile errors when compiled on 32-bit systems:
```
policy/feerate.cpp:23:22: warning: result of comparison of constant 9223372036854775807 with expression of type 'size_t' (aka 'unsigned int') is always true [-Wtautological-constant-out-of-range-compare]
assert(nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max()));
```
Fix all issues by making it arch-independent. Also, fix `{}` style according to dev notes.
ACKs for top commit:
theStack:
re-ACK fafd121026c4f1e25d498983e4f88c119516552b
promag:
Code review ACK fafd121026c4f1e25d498983e4f88c119516552b.
Tree-SHA512: e16f75bad9ee8088b87e873906d9b5633449417a6996a226a2f37d33a2b7d4f2fd91df68998a77e52163de20b40c57fadabe7fe3502e599cbb98494178591833
Diffstat (limited to 'src/policy/feerate.h')
-rw-r--r-- | src/policy/feerate.h | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/policy/feerate.h b/src/policy/feerate.h index 0e4f9914b8..d296d32774 100644 --- a/src/policy/feerate.h +++ b/src/policy/feerate.h @@ -39,20 +39,17 @@ public: // 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). The size in bytes must not exceed (2^63 - 1). + /** Constructor for a fee rate in satoshis per kvB (sat/kvB). * - * Passing an nBytes value of COIN (1e8) returns a fee rate in satoshis per vB (sat/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 CAmount fee rate to construct with - * @param[in] nBytes size_t bytes (units) to construct with */ - CFeeRate(const CAmount& nFeePaid, size_t nBytes); + CFeeRate(const CAmount& nFeePaid, uint32_t num_bytes); /** * Return the fee in satoshis for the given size in bytes. */ - CAmount GetFee(size_t nBytes) const; + CAmount GetFee(uint32_t num_bytes) const; /** * Return the fee in satoshis for a size of 1000 bytes */ |