Inline checked mul function back into weight module
A while back we move all the 'fee' stuff into a separate module because I thought it would help with clarity - I was wrong. Move the checked mul function back into the `weight` module on the main `Weight` impl block. Internal change only - code move.
This commit is contained in:
parent
a8610a937b
commit
251e6a85da
|
@ -181,20 +181,6 @@ crate::internal_macros::impl_op_for_references! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Weight {
|
|
||||||
/// Checked fee rate multiplication.
|
|
||||||
///
|
|
||||||
/// Computes the absolute fee amount for a given [`FeeRate`] at this weight. When the resulting
|
|
||||||
/// fee is a non-integer amount, the amount is rounded up, ensuring that the transaction fee is
|
|
||||||
/// enough instead of falling short if rounded down.
|
|
||||||
///
|
|
||||||
/// Returns [`None`] if overflow occurred.
|
|
||||||
#[must_use]
|
|
||||||
pub const fn checked_mul_by_fee_rate(self, fee_rate: FeeRate) -> Option<Amount> {
|
|
||||||
fee_rate.checked_mul_by_weight(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -10,7 +10,7 @@ use arbitrary::{Arbitrary, Unstructured};
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
use crate::CheckedSum;
|
use crate::{Amount, CheckedSum, FeeRate};
|
||||||
|
|
||||||
/// The factor that non-witness serialization data is multiplied by during weight calculation.
|
/// The factor that non-witness serialization data is multiplied by during weight calculation.
|
||||||
pub const WITNESS_SCALE_FACTOR: usize = 4;
|
pub const WITNESS_SCALE_FACTOR: usize = 4;
|
||||||
|
@ -162,6 +162,18 @@ impl Weight {
|
||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checked fee rate multiplication.
|
||||||
|
///
|
||||||
|
/// Computes the absolute fee amount for a given [`FeeRate`] at this weight. When the resulting
|
||||||
|
/// fee is a non-integer amount, the amount is rounded up, ensuring that the transaction fee is
|
||||||
|
/// enough instead of falling short if rounded down.
|
||||||
|
///
|
||||||
|
/// Returns [`None`] if overflow occurred.
|
||||||
|
#[must_use]
|
||||||
|
pub const fn checked_mul_by_fee_rate(self, fee_rate: FeeRate) -> Option<Amount> {
|
||||||
|
fee_rate.checked_mul_by_weight(self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Alternative will display the unit.
|
/// Alternative will display the unit.
|
||||||
|
|
Loading…
Reference in New Issue