Merge rust-bitcoin/rust-bitcoin#3604: Add constructor to `FeeRate`
b96501981f
feat(units): add kvb constructor to `FeeRate` (Rob N) Pull request description: This is partially to check my understanding. I did poorly in physics class as part of my misunderstanding of unit conversions. The `feefilter` message expresses the fee as satoshis per 1,000 vbyte, see the [p2p handling](1dda1892b6/src/net_processing.cpp (L5331)
) which calls [this function](https://github.com/bitcoin/bitcoin/blob/master/src/policy/feerate.h#L63) on the mempool. I presume all that needs to happen to express this in `kwu` is to divide by 4, but ideally a `FeeRate` may be constructed directly from a `feefilter` message using a constructor. My conversion is (sat / kvb * kvb / 4 kwu) ACKs for top commit: sanket1729: ACKb96501981f
. apoelstra: ACK b96501981ffef1d32c839cd44861736ce3683964; successfully ran local tests tcharding: ACKb96501981f
Tree-SHA512: 5aec75d253a0955bfe0bdec42d2e13b69602da057ec7769126399473799455f8df1691f98f6e8dc1d6338958e05702a846d0a5f00bce6aa9079c2ceb0c54df0f
This commit is contained in:
commit
708522394b
|
@ -62,6 +62,9 @@ impl FeeRate {
|
|||
/// Constructs a new [`FeeRate`] from satoshis per virtual bytes without overflow check.
|
||||
pub const fn from_sat_per_vb_unchecked(sat_vb: u64) -> Self { FeeRate(sat_vb * (1000 / 4)) }
|
||||
|
||||
/// Constructs a new [`FeeRate`] from satoshis per kilo virtual bytes (1,000 vbytes).
|
||||
pub const fn from_sat_per_kvb(sat_kvb: u64) -> Self { FeeRate(sat_kvb / 4) }
|
||||
|
||||
/// Returns raw fee rate.
|
||||
///
|
||||
/// Can be used instead of `into()` to avoid inference issues.
|
||||
|
|
Loading…
Reference in New Issue