pub struct ChargeTransactionPayment<T: Config>(_);
Expand description
Require the transactor pay for themselves and maybe include a tip to gain additional priority in the queue.
Transaction Validity
This extension sets the priority
field of TransactionValidity
depending on the amount
of tip being paid per weight unit.
Operational transactions will receive an additional priority bump, so that they are normally considered before regular transactions.
Implementations
impl<T: Config> ChargeTransactionPayment<T> where
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: Send + Sync + FixedPointOperand,
impl<T: Config> ChargeTransactionPayment<T> where
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: Send + Sync + FixedPointOperand,
pub fn from(
fee: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance
) -> Self
pub fn from(
fee: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance
) -> Self
utility constructor. Used only in client/factory code.
Returns the tip as being choosen by the transaction sender.
pub fn get_priority(
info: &DispatchInfoOf<T::Call>,
len: usize,
tip: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance,
final_fee: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance
) -> TransactionPriority
pub fn get_priority(
info: &DispatchInfoOf<T::Call>,
len: usize,
tip: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance,
final_fee: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance
) -> TransactionPriority
Get an appropriate priority for a transaction with the given DispatchInfo
, encoded length
and user-included tip.
The priority is based on the amount of tip
the user is willing to pay per unit of either
weight
or length
, depending which one is more limitting. For Operational
extrinsics
we add a “virtual tip” to the calculations.
The formula should simply be tip / bounded_{weight|length}
, but since we are using
integer division, we have no guarantees it’s going to give results in any reasonable
range (might simply end up being zero). Hence we use a scaling factor:
tip * (max_block_{weight|length} / bounded_{weight|length})
, since given current
state of-the-art blockchains, number of per-block transactions is expected to be in a
range reasonable enough to not saturate the Balance
type while multiplying by the tip.
Trait Implementations
impl<T: Config> Decode for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: HasCompact,
impl<T: Config> Decode for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: HasCompact,
impl<T: Config> Encode for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: HasCompact,
impl<T: Config> Encode for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: HasCompact,
impl<T: PartialEq + Config> PartialEq<ChargeTransactionPayment<T>> for ChargeTransactionPayment<T>
impl<T: PartialEq + Config> PartialEq<ChargeTransactionPayment<T>> for ChargeTransactionPayment<T>
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
impl<T: Config> SignedExtension for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: Send + Sync + From<u64> + FixedPointOperand,
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
impl<T: Config> SignedExtension for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: Send + Sync + From<u64> + FixedPointOperand,
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
Unique identifier of this signed extension. Read more
type AdditionalSigned = ()
type AdditionalSigned = ()
Any additional data that will go into the signed payload. This may be created dynamically
from the transaction using the additional_signed
function. Read more
type Pre = (<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, Self::AccountId, <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo)
type Pre = (<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, Self::AccountId, <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo)
The type that encodes information that can be passed from pre_dispatch to post-dispatch.
Construct any additional data that should be in the signed payload of the transaction. Can also perform any pre-signature-verification checks and return an error if needed. Read more
fn validate(
&self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize
) -> TransactionValidity
fn validate(
&self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize
) -> TransactionValidity
Validate a signed transaction for the transaction queue. Read more
fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize
) -> Result<Self::Pre, TransactionValidityError>
fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize
) -> Result<Self::Pre, TransactionValidityError>
Do any pre-flight stuff for a signed transaction. Read more
fn post_dispatch(
pre: Self::Pre,
info: &DispatchInfoOf<Self::Call>,
post_info: &PostDispatchInfoOf<Self::Call>,
len: usize,
_result: &DispatchResult
) -> Result<(), TransactionValidityError>
fn post_dispatch(
pre: Self::Pre,
info: &DispatchInfoOf<Self::Call>,
post_info: &PostDispatchInfoOf<Self::Call>,
len: usize,
_result: &DispatchResult
) -> Result<(), TransactionValidityError>
Do any post-flight stuff for an extrinsic. Read more
fn validate_unsigned(
_call: &Self::Call,
_info: &<Self::Call as Dispatchable>::Info,
_len: usize
) -> Result<ValidTransaction, TransactionValidityError>
fn validate_unsigned(
_call: &Self::Call,
_info: &<Self::Call as Dispatchable>::Info,
_len: usize
) -> Result<ValidTransaction, TransactionValidityError>
Validate an unsigned transaction for the transaction queue. Read more
fn pre_dispatch_unsigned(
call: &Self::Call,
info: &<Self::Call as Dispatchable>::Info,
len: usize
) -> Result<Self::Pre, TransactionValidityError>
fn pre_dispatch_unsigned(
call: &Self::Call,
info: &<Self::Call as Dispatchable>::Info,
len: usize
) -> Result<Self::Pre, TransactionValidityError>
Do any pre-flight stuff for a unsigned transaction. Read more
impl<T: Config> TypeInfo for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: HasCompact,
T: Config + 'static,
impl<T: Config> TypeInfo for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: HasCompact,
T: Config + 'static,
impl<T: Config> EncodeLike<ChargeTransactionPayment<T>> for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: HasCompact,
Auto Trait Implementations
impl<T> RefUnwindSafe for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: RefUnwindSafe,
impl<T> Send for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: Send,
impl<T> Sync for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: Sync,
impl<T> Unpin for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: Unpin,
impl<T> UnwindSafe for ChargeTransactionPayment<T> where
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘimpl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘimpl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
pub fn blake2_128_concat(&self) -> Vec<u8, Global>ⓘ
pub fn twox_64_concat(&self) -> Vec<u8, Global>ⓘ
The counterpart to unchecked_from
.
Consume self to return an equivalent value of T
.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more