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: &BlockId<B::Block>, 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: &BlockId<B::Block>, 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: &BlockId<B::Block>, 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: &BlockId<B::Block>, 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: &BlockId<B::Block>, parent: &BlockId<B::Block>, 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: &BlockId<B::Block>, 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> !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · 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> DynClone for Twhere T: Clone,

source§

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

source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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, Outer> IsWrappedBy<Outer> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatedConversion for T

source§

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

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

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

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

impl<T> ToOwned for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
source§

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

source§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
§

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

§

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
§

impl<T> JsonSchemaMaybe for T