mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 03:18:01 +00:00
Pass transaction source to validate_transaction (#5366)
* WiP * Support source in the runtime API. * Finish implementation in txpool. * Fix warning. * Fix tests. * Apply suggestions from code review Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-Authored-By: Nikolay Volf <nikvolf@gmail.com> * Extra changes. * Fix test and benches. * fix test * Fix test & benches again. * Fix tests. * Update bumpalo * Fix doc test. * Fix doctest. * Fix doctest. Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
@@ -28,7 +28,8 @@ use serde::{Serialize, Deserialize, de::DeserializeOwned};
|
||||
use sp_core::{self, Hasher, TypeId, RuntimeDebug};
|
||||
use crate::codec::{Codec, Encode, Decode};
|
||||
use crate::transaction_validity::{
|
||||
ValidTransaction, TransactionValidity, TransactionValidityError, UnknownTransaction,
|
||||
ValidTransaction, TransactionSource, TransactionValidity, TransactionValidityError,
|
||||
UnknownTransaction,
|
||||
};
|
||||
use crate::generic::{Digest, DigestItem};
|
||||
pub use sp_arithmetic::traits::{
|
||||
@@ -851,6 +852,7 @@ pub trait Applyable: Sized + Send + Sync {
|
||||
/// Checks to see if this is a valid *transaction*. It returns information on it if so.
|
||||
fn validate<V: ValidateUnsigned<Call=Self::Call>>(
|
||||
&self,
|
||||
source: TransactionSource,
|
||||
info: Self::DispatchInfo,
|
||||
len: usize,
|
||||
) -> TransactionValidity;
|
||||
@@ -897,7 +899,7 @@ pub trait ValidateUnsigned {
|
||||
///
|
||||
/// Changes made to storage WILL be persisted if the call returns `Ok`.
|
||||
fn pre_dispatch(call: &Self::Call) -> Result<(), TransactionValidityError> {
|
||||
Self::validate_unsigned(call)
|
||||
Self::validate_unsigned(TransactionSource::InBlock, call)
|
||||
.map(|_| ())
|
||||
.map_err(Into::into)
|
||||
}
|
||||
@@ -908,7 +910,7 @@ pub trait ValidateUnsigned {
|
||||
/// whether the transaction would panic if it were included or not.
|
||||
///
|
||||
/// Changes made to storage should be discarded by caller.
|
||||
fn validate_unsigned(call: &Self::Call) -> TransactionValidity;
|
||||
fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity;
|
||||
}
|
||||
|
||||
/// Opaque data type that may be destructured into a series of raw byte slices (which represent
|
||||
|
||||
Reference in New Issue
Block a user