mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
seal: Refactor ext_gas_price (#6478)
* seal: Refactor ext_gas_price * Remove seals dependency on pallet_transaction_payment * Add weight as an argument to ext_gas_price * Fixed documentation nits from review * Do not use unchecked math even in test code
This commit is contained in:
committed by
GitHub
parent
f36b78570f
commit
a3a42f599a
@@ -51,7 +51,7 @@ use sp_runtime::{
|
||||
},
|
||||
traits::{
|
||||
Zero, Saturating, SignedExtension, SaturatedConversion, Convert, Dispatchable,
|
||||
DispatchInfoOf, PostDispatchInfoOf, UniqueSaturatedFrom, UniqueSaturatedInto,
|
||||
DispatchInfoOf, PostDispatchInfoOf,
|
||||
},
|
||||
};
|
||||
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||
@@ -340,23 +340,6 @@ impl<T: Trait> Module<T> where
|
||||
tip
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
/// Compute the fee for the specified weight.
|
||||
///
|
||||
/// This fee is already adjusted by the per block fee adjustment factor and is therefore the
|
||||
/// share that the weight contributes to the overall fee of a transaction.
|
||||
///
|
||||
/// This function is generic in order to supply the contracts module with a way to calculate the
|
||||
/// gas price. The contracts module is not able to put the necessary `BalanceOf<T>` constraints
|
||||
/// on its trait. This function is not to be used by this module.
|
||||
pub fn weight_to_fee_with_adjustment<Balance>(weight: Weight) -> Balance where
|
||||
Balance: UniqueSaturatedFrom<u128>
|
||||
{
|
||||
let fee: u128 = Self::weight_to_fee(weight).unique_saturated_into();
|
||||
Balance::unique_saturated_from(NextFeeMultiplier::get().saturating_mul_acc_int(fee))
|
||||
}
|
||||
|
||||
fn weight_to_fee(weight: Weight) -> BalanceOf<T> {
|
||||
// cap the weight to the maximum defined in runtime, otherwise it will be the
|
||||
@@ -366,6 +349,20 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Convert<Weight, BalanceOf<T>> for Module<T> where
|
||||
T: Trait,
|
||||
BalanceOf<T>: FixedPointOperand,
|
||||
{
|
||||
/// Compute the fee for the specified weight.
|
||||
///
|
||||
/// This fee is already adjusted by the per block fee adjustment factor and is therefore the
|
||||
/// share that the weight contributes to the overall fee of a transaction. It is mainly
|
||||
/// for informational purposes and not used in the actual fee calculation.
|
||||
fn convert(weight: Weight) -> BalanceOf<T> {
|
||||
NextFeeMultiplier::get().saturating_mul_int(Self::weight_to_fee(weight))
|
||||
}
|
||||
}
|
||||
|
||||
/// Require the transactor pay for themselves and maybe include a tip to gain additional priority
|
||||
/// in the queue.
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user