Trait g1_runtime::WeightToFeePolynomial
pub trait WeightToFeePolynomial {
type Balance: BaseArithmetic + From<u32> + Copy + Unsigned;
// Required method
fn polynomial() -> SmallVec<[WeightToFeeCoefficient<Self::Balance>; 4]>;
}
Expand description
A trait that describes the weight to fee calculation as polynomial.
An implementor should only implement the polynomial
function.
Required Associated Types§
Required Methods§
fn polynomial() -> SmallVec<[WeightToFeeCoefficient<Self::Balance>; 4]>
fn polynomial() -> SmallVec<[WeightToFeeCoefficient<Self::Balance>; 4]>
Returns a polynomial that describes the weight to fee conversion.
This is the only function that should be manually implemented. Please note
that all calculation is done in the probably unsigned Balance
type. This means
that the order of coefficients is important as putting the negative coefficients
first will most likely saturate the result to zero mid evaluation.
Object Safety§
Implementations on Foreign Types§
source§impl<Balance, Runtime, Target> WeightToFeePolynomial for WeightToFeeImpl<Balance, Runtime, Target>
impl<Balance, Runtime, Target> WeightToFeePolynomial for WeightToFeeImpl<Balance, Runtime, Target>
Trait implementation for converting transaction weight to fee.
This implementation is only included when the “constant-fees” feature is not enabled.
source§fn polynomial(
) -> SmallVec<[WeightToFeeCoefficient<<WeightToFeeImpl<Balance, Runtime, Target> as WeightToFeePolynomial>::Balance>; 4]>
fn polynomial( ) -> SmallVec<[WeightToFeeCoefficient<<WeightToFeeImpl<Balance, Runtime, Target> as WeightToFeePolynomial>::Balance>; 4]>
Function to get the polynomial coefficients for weight to fee conversion.
This function calculates the polynomial coefficients for converting transaction weight to fee. If the current block weight and length are less than a fraction of the block max weight and length, and the fee multiplier is one, it returns zero. Otherwise, it calculates the coefficients based on the extrinsic base weight mapped to 5 cents.