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>

source

pub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self

Create a new transaction pool.

source

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

source

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.

source

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

source

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.

source

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.

source

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.

source

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.

source

pub async fn prune_tags( &self, at: <B::Block as BlockT>::Hash, tags: impl IntoIterator<Item = Tag>, known_imported_hashes: impl IntoIterator<Item = <<B as ChainApi>::Block as Block>::Hash> + Clone, ) -> Result<(), B::Error>

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:

  1. Provide that tag directly
  2. 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.

source

pub fn hash_of( &self, xt: &<<B as ChainApi>::Block as Block>::Extrinsic, ) -> <<B as ChainApi>::Block as Block>::Hash

Returns transaction hash

source

pub fn validated_pool(&self) -> &ValidatedPool<B>

get a reference to the underlying validated pool.

Trait Implementations§

source§

impl<B: ChainApi> Clone for Pool<B>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedConversion for T

source§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
source§

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
source§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

source§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

source§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatedConversion for T

source§

fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
source§

fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
source§

impl<T, S> UniqueSaturatedInto<T> for S
where T: Bounded, S: TryInto<T>,

source§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> JsonSchemaMaybe for T