Struct sc_transaction_pool::Pool
source · pub struct Pool<B: ChainApi> { /* private fields */ }
Expand description
Extrinsics pool that performs validation.
Implementations§
source§impl<B: ChainApi> Pool<B>
impl<B: ChainApi> Pool<B>
sourcepub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self
pub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self
Create a new transaction pool.
sourcepub async fn submit_at(
&self,
at: <B::Block as BlockT>::Hash,
source: TransactionSource,
xts: impl IntoIterator<Item = <<B as ChainApi>::Block as Block>::Extrinsic>,
) -> Result<Vec<Result<<<B as ChainApi>::Block as Block>::Hash, B::Error>>, B::Error>
pub async fn submit_at( &self, at: <B::Block as BlockT>::Hash, source: TransactionSource, xts: impl IntoIterator<Item = <<B as ChainApi>::Block as Block>::Extrinsic>, ) -> Result<Vec<Result<<<B as ChainApi>::Block as Block>::Hash, B::Error>>, B::Error>
Imports a bunch of unverified extrinsics to the pool
sourcepub async fn resubmit_at(
&self,
at: <B::Block as BlockT>::Hash,
source: TransactionSource,
xts: impl IntoIterator<Item = <<B as ChainApi>::Block as Block>::Extrinsic>,
) -> Result<Vec<Result<<<B as ChainApi>::Block as Block>::Hash, B::Error>>, B::Error>
pub async fn resubmit_at( &self, at: <B::Block as BlockT>::Hash, source: TransactionSource, xts: impl IntoIterator<Item = <<B as ChainApi>::Block as Block>::Extrinsic>, ) -> Result<Vec<Result<<<B as ChainApi>::Block as Block>::Hash, B::Error>>, B::Error>
Resubmit the given extrinsics to the pool.
This does not check if a transaction is banned, before we verify it again.
sourcepub async fn submit_one(
&self,
at: <B::Block as BlockT>::Hash,
source: TransactionSource,
xt: <<B as ChainApi>::Block as Block>::Extrinsic,
) -> Result<<<B as ChainApi>::Block as Block>::Hash, B::Error>
pub async fn submit_one( &self, at: <B::Block as BlockT>::Hash, source: TransactionSource, xt: <<B as ChainApi>::Block as Block>::Extrinsic, ) -> Result<<<B as ChainApi>::Block as Block>::Hash, B::Error>
Imports one unverified extrinsic to the pool
sourcepub async fn submit_and_watch(
&self,
at: <B::Block as BlockT>::Hash,
source: TransactionSource,
xt: <<B as ChainApi>::Block as Block>::Extrinsic,
) -> Result<Watcher<<<B as ChainApi>::Block as Block>::Hash, <<B as ChainApi>::Block as Block>::Hash>, B::Error>
pub async fn submit_and_watch( &self, at: <B::Block as BlockT>::Hash, source: TransactionSource, xt: <<B as ChainApi>::Block as Block>::Extrinsic, ) -> Result<Watcher<<<B as ChainApi>::Block as Block>::Hash, <<B as ChainApi>::Block as Block>::Hash>, B::Error>
Import a single extrinsic and starts to watch its progress in the pool.
sourcepub fn resubmit(
&self,
revalidated_transactions: HashMap<<<B as ChainApi>::Block as Block>::Hash, ValidatedTransaction<<<B as ChainApi>::Block as Block>::Hash, <<B as ChainApi>::Block as Block>::Extrinsic, <B as ChainApi>::Error>>,
)
pub fn resubmit( &self, revalidated_transactions: HashMap<<<B as ChainApi>::Block as Block>::Hash, ValidatedTransaction<<<B as ChainApi>::Block as Block>::Hash, <<B as ChainApi>::Block as Block>::Extrinsic, <B as ChainApi>::Error>>, )
Resubmit some transaction that were validated elsewhere.
sourcepub fn prune_known(
&self,
at: &BlockId<B::Block>,
hashes: &[<<B as ChainApi>::Block as Block>::Hash],
) -> Result<(), B::Error>
pub fn prune_known( &self, at: &BlockId<B::Block>, hashes: &[<<B as ChainApi>::Block as Block>::Hash], ) -> Result<(), B::Error>
Prunes known ready transactions.
Used to clear the pool from transactions that were part of recently imported block.
The main difference from the prune
is that we do not revalidate any transactions
and ignore unknown passed hashes.
sourcepub async fn prune(
&self,
at: <B::Block as BlockT>::Hash,
parent: <B::Block as BlockT>::Hash,
extrinsics: &[<<B as ChainApi>::Block as Block>::Extrinsic],
) -> Result<(), B::Error>
pub async fn prune( &self, at: <B::Block as BlockT>::Hash, parent: <B::Block as BlockT>::Hash, extrinsics: &[<<B as ChainApi>::Block as Block>::Extrinsic], ) -> Result<(), B::Error>
Prunes ready transactions.
Used to clear the pool from transactions that were part of recently imported block.
To perform pruning we need the tags that each extrinsic provides and to avoid calling
into runtime too often we first lookup all extrinsics that are in the pool and get
their provided tags from there. Otherwise we query the runtime at the parent
block.
Prunes ready transactions that provide given list of tags.
Given tags are assumed to be always provided now, so all transactions in the Future Queue that require that particular tag (and have other requirements satisfied) are promoted to Ready Queue.
Moreover for each provided tag we remove transactions in the pool that:
- Provide that tag directly
- Are a dependency of pruned transaction.
Returns transactions that have been removed from the pool and must be reverified before reinserting to the pool.
By removing predecessor transactions as well we might actually end up
pruning too much, so all removed transactions are reverified against
the runtime (validate_transaction
) to make sure they are invalid.
However we avoid revalidating transactions that are contained within
the second parameter of known_imported_hashes
. These transactions
(if pruned) are not revalidated and become temporarily banned to
prevent importing them in the (near) future.
sourcepub fn hash_of(
&self,
xt: &<<B as ChainApi>::Block as Block>::Extrinsic,
) -> <<B as ChainApi>::Block as Block>::Hash
pub fn hash_of( &self, xt: &<<B as ChainApi>::Block as Block>::Extrinsic, ) -> <<B as ChainApi>::Block as Block>::Hash
Returns transaction hash
sourcepub fn validated_pool(&self) -> &ValidatedPool<B>
pub fn validated_pool(&self) -> &ValidatedPool<B>
get a reference to the underlying validated pool.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for Pool<B>
impl<B> !RefUnwindSafe for Pool<B>
impl<B> Send for Pool<B>
impl<B> Sync for Pool<B>
impl<B> Unpin for Pool<B>
impl<B> !UnwindSafe for Pool<B>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.