Rename rhs to weight

In ops functions we typically use `rhs` but for the more unconventional
`checked_*_by_*` functions lets use a more descriptive parameter name.

This is an internal change but the api files are updated because the
paramater names appear in the api text files.
This commit is contained in:
Tobin C. Harding 2024-12-23 14:40:56 +11:00
parent 35f1e8641f
commit 0a16382fa3
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
2 changed files with 6 additions and 6 deletions

View File

@ -369,8 +369,8 @@ impl Amount {
/// ```
#[cfg(feature = "alloc")]
#[must_use]
pub const fn checked_div_by_weight_ceil(self, rhs: Weight) -> Option<FeeRate> {
let wu = rhs.to_wu();
pub const fn checked_div_by_weight_ceil(self, weight: Weight) -> Option<FeeRate> {
let wu = weight.to_wu();
// No `?` operator in const context.
if let Some(sats) = self.0.checked_mul(1_000) {
if let Some(wu_minus_one) = wu.checked_sub(1) {
@ -392,10 +392,10 @@ impl Amount {
/// Returns [`None`] if overflow occurred.
#[cfg(feature = "alloc")]
#[must_use]
pub const fn checked_div_by_weight_floor(self, rhs: Weight) -> Option<FeeRate> {
pub const fn checked_div_by_weight_floor(self, weight: Weight) -> Option<FeeRate> {
// No `?` operator in const context.
match self.0.checked_mul(1_000) {
Some(res) => match res.checked_div(rhs.to_wu()) {
Some(res) => match res.checked_div(weight.to_wu()) {
Some(fee_rate) => Some(FeeRate::from_sat_per_kwu(fee_rate)),
None => None,
},

View File

@ -108,9 +108,9 @@ impl FeeRate {
///
/// [`None`] is returned if an overflow occurred.
#[must_use]
pub const fn checked_mul_by_weight(self, rhs: Weight) -> Option<Amount> {
pub const fn checked_mul_by_weight(self, weight: Weight) -> Option<Amount> {
// No `?` operator in const context.
match self.0.checked_mul(rhs.to_wu()) {
match self.0.checked_mul(weight.to_wu()) {
Some(mul_res) => match mul_res.checked_add(999) {
Some(add_res) => Some(Amount::from_sat(add_res / 1000)),
None => None,