mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 13:51:11 +00:00
Add WeightToFee and LengthToFee impls to transaction-payment Runtime API (#13110)
* Add WeightToFee and LengthToFee impls to RPC * Remove RPC additions * Update frame/transaction-payment/rpc/runtime-api/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Add comments to length_to_fee and weight_to_fee Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -612,11 +612,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn length_to_fee(length: u32) -> BalanceOf<T> {
|
||||
/// Compute the length portion of a fee by invoking the configured `LengthToFee` impl.
|
||||
pub fn length_to_fee(length: u32) -> BalanceOf<T> {
|
||||
T::LengthToFee::weight_to_fee(&Weight::from_ref_time(length as u64))
|
||||
}
|
||||
|
||||
fn weight_to_fee(weight: Weight) -> BalanceOf<T> {
|
||||
/// Compute the unadjusted portion of the weight fee by invoking the configured `WeightToFee`
|
||||
/// impl. Note that the input `weight` is capped by the maximum block weight before computation.
|
||||
pub fn weight_to_fee(weight: Weight) -> BalanceOf<T> {
|
||||
// cap the weight to the maximum defined in runtime, otherwise it will be the
|
||||
// `Bounded` maximum of its data type, which is not desired.
|
||||
let capped_weight = weight.min(T::BlockWeights::get().max_block);
|
||||
|
||||
Reference in New Issue
Block a user