This allows `FeeRate`s to be stored inside `const`s.
For example:
const MY_FEE_RATE: FeeRate = FeeRate::from_sat_per_vb(10.0);
Unfortunately, floating point maths inside const expressions is
still unstable, hence we cannot make `from_btc_per_kvb` const.
#### Changed
- Updated `electrum-client` to version `0.7`
+### Wallet
+#### Changed
+- `FeeRate` constructors `from_sat_per_vb` and `default_min_relay_fee` are now `const` functions
+
## [v0.4.0] - [v0.3.0]
### Keys
}
/// Create a new instance of [`FeeRate`] given a float fee rate in satoshi/vbyte
- pub fn from_sat_per_vb(sat_per_vb: f32) -> Self {
+ pub const fn from_sat_per_vb(sat_per_vb: f32) -> Self {
FeeRate(sat_per_vb)
}
/// Create a new [`FeeRate`] with the default min relay fee value
- pub fn default_min_relay_fee() -> Self {
+ pub const fn default_min_relay_fee() -> Self {
FeeRate(1.0)
}
/// Confirmed in block height, `None` means unconfirmed
pub height: Option<u32>,
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn can_store_feerate_in_const() {
+ const _MY_RATE: FeeRate = FeeRate::from_sat_per_vb(10.0);
+ const _MIN_RELAY: FeeRate = FeeRate::default_min_relay_fee();
+ }
+}