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

Add dedicated FeePolynomial struct #13612

Merged
merged 8 commits into from
Mar 15, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add docs
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  • Loading branch information
ggwpez committed Mar 15, 2023
commit 005138c9ba55a4c34a593d93dfa8b88cc29839e4
13 changes: 12 additions & 1 deletion primitives/weights/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,18 @@ pub type WeightToFeeCoefficients<T> = SmallVec<[WeightToFeeCoefficient<T>; 4]>;

/// A list of coefficients that represent a polynomial.
///
/// Can be [eval](Self::eval)uated at a specific `u64` to get the fee.
/// Can be [eval](Self::eval)uated at a specific `u64` to get the fee. The evaluations happens by
/// summing up all term [results](`WeightToFeeCoefficient::saturating_eval`). The order of the
/// coefficients matters since it uses saturating arithmetic. This struct does therefore not model a
/// polynomial in the mathematical sense (polynomial ring).
///
/// For visualization purposes, the formula looks like this:
///
/// ```ignore
/// (c[0].frac * x^(c[0].degree) + c[0].integer * x^(c[0].degree)) * (-1 * c[0].negative)
/// + (c[1].frac * x^(c[1].degree) + c[1].integer * x^(c[1].degree)) * (-1 * c[1].negative)
/// + ...
/// ```
pub struct FeePolynomial<Balance> {
coefficients: SmallVec<[WeightToFeeCoefficient<Balance>; 4]>,
}
Expand Down