Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

More efficient identity and multiplier weight to fee #11226

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions frame/support/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,10 @@ where
degree: 1,
})
}

fn calc(weight: &Weight) -> Self::Balance {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this API a bit strange, that now polynomial still needs to be implemented but it is not really used, right? Nonetheless, looks like a reasonable micro optimization.

Self::Balance::saturated_from(*weight)
}
}

/// Implementor of [`WeightToFeePolynomial`] that uses a constant multiplier.
Expand Down Expand Up @@ -738,6 +742,10 @@ where
degree: 1,
})
}

fn calc(weight: &Weight) -> Self::Balance {
Self::Balance::saturated_from(*weight).saturating_mul(M::get())
}
}

/// A struct holding value for each `DispatchClass`.
Expand Down