Remove `fee_vb`

This is redundant given Weight::from_vb is provided.  After converting
to a weight_unit, use to_fee().
This commit is contained in:
yancy 2025-02-04 15:13:56 -06:00
parent 73b14d03b9
commit a7526b6a70
2 changed files with 1 additions and 33 deletions

View File

@ -22,30 +22,6 @@ pub use self::{
pub mod fee_rate {
/// Re-export everything from the [`units::fee_rate`] module.
pub use units::fee_rate::FeeRate;
#[cfg(test)]
mod tests {
use internals::ToU64 as _;
use super::*;
#[test]
fn fee_convenience_functions_agree() {
use hex::test_hex_unwrap as hex;
use crate::consensus::Decodable;
use crate::transaction::{Transaction, TransactionExt as _};
const SOME_TX: &str = "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000";
let raw_tx = hex!(SOME_TX);
let tx: Transaction = Decodable::consensus_decode(&mut raw_tx.as_slice()).unwrap();
let rate = FeeRate::from_sat_per_vb(1).expect("1 sat/byte is valid");
assert_eq!(rate.fee_vb(tx.vsize().to_u64()), rate.to_fee(tx.weight()));
}
}
}
/// Provides absolute and relative locktimes.

View File

@ -134,6 +134,7 @@ impl FeeRate {
/// This is equivalent to converting `vb` to [`Weight`] using [`Weight::from_vb`] and then calling
/// `Self::fee_wu(weight)`.
#[must_use]
#[deprecated(since = "TBD", note = "use Weight::from_vb and then `to_fee()` instead")]
pub fn fee_vb(self, vb: u64) -> Option<Amount> {
Weight::from_vb(vb).and_then(|w| self.to_fee(w))
}
@ -234,15 +235,6 @@ mod tests {
assert_eq!(fee_rate.to_fee(weight).unwrap(), Amount::from_sat_unchecked(6));
}
#[test]
fn fee_vb() {
let fee_overflow = FeeRate::from_sat_per_kwu(10).fee_vb(Weight::MAX.to_wu());
assert!(fee_overflow.is_none());
let fee_rate = FeeRate::from_sat_per_vb(2).unwrap();
assert_eq!(fee_rate.fee_vb(3).unwrap(), Amount::from_sat_unchecked(6));
}
#[test]
fn checked_weight_mul() {
let weight = Weight::from_vb(10).unwrap();