Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce TransactionExtensionPipeline to use instead of tuple for pipeline with more than 12 elements #6571

Closed
wants to merge 14 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ use super::{

mod as_transaction_extension;
mod dispatch_transaction;
mod transaction_extension_pipeline;
#[allow(deprecated)]
pub use as_transaction_extension::AsTransactionExtension;
pub use dispatch_transaction::DispatchTransaction;
pub use transaction_extension_pipeline::{
TransactionExtensionPipeline, TransactionExtensionPipelineImplicit,
};

/// Shortcut for the result value of the `validate` function.
pub type ValidateResult<Val, Call> =
Expand Down Expand Up @@ -605,14 +609,17 @@ impl<Call: Dispatchable> TransactionExtension<Call> for Tuple {
impl<Call: Dispatchable> TransactionExtension<Call> for () {
const IDENTIFIER: &'static str = "UnitTransactionExtension";
type Implicit = ();
#[inline]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TransactionExtensionPipeline take 32 generics that defaults to (), so I inlined methods here so hopefully the code gets optimized by the compiler.

fn implicit(&self) -> sp_std::result::Result<Self::Implicit, TransactionValidityError> {
Ok(())
}
type Val = ();
type Pre = ();
#[inline]
fn weight(&self, _call: &Call) -> Weight {
Weight::zero()
}
#[inline]
fn validate(
&self,
origin: <Call as Dispatchable>::RuntimeOrigin,
Expand All @@ -628,6 +635,7 @@ impl<Call: Dispatchable> TransactionExtension<Call> for () {
> {
Ok((ValidTransaction::default(), (), origin))
}
#[inline]
fn prepare(
self,
_val: (),
Expand All @@ -638,4 +646,53 @@ impl<Call: Dispatchable> TransactionExtension<Call> for () {
) -> Result<(), TransactionValidityError> {
Ok(())
}
#[inline]
fn metadata() -> Vec<TransactionExtensionMetadata> {
vec![]
}
#[inline]
fn post_dispatch(
_pre: Self::Pre,
_info: &DispatchInfoOf<Call>,
_post_info: &mut PostDispatchInfoOf<Call>,
_len: usize,
_result: &DispatchResult,
) -> Result<(), TransactionValidityError> {
Ok(())
}
#[inline]
fn bare_validate(
_call: &Call,
_info: &DispatchInfoOf<Call>,
_len: usize,
) -> TransactionValidity {
Ok(ValidTransaction::default())
}
#[inline]
fn bare_post_dispatch(
_info: &DispatchInfoOf<Call>,
_post_info: &mut PostDispatchInfoOf<Call>,
_len: usize,
_result: &DispatchResult,
) -> Result<(), TransactionValidityError> {
Ok(())
}
#[inline]
fn post_dispatch_details(
_pre: Self::Pre,
_info: &DispatchInfoOf<Call>,
_post_info: &PostDispatchInfoOf<Call>,
_len: usize,
_result: &DispatchResult,
) -> Result<Weight, TransactionValidityError> {
Ok(Weight::zero())
}
#[inline]
fn bare_validate_and_prepare(
_call: &Call,
_info: &DispatchInfoOf<Call>,
_len: usize,
) -> Result<(), TransactionValidityError> {
Ok(())
}
}
Loading
Loading