Struct sc_transaction_graph::Pool
source · [−]pub struct Pool<B: ChainApi> { /* private fields */ }
Expand description
Extrinsics pool that performs validation.
Implementations
sourceimpl<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: &BlockId<B::Block>,
source: TransactionSource,
xts: impl IntoIterator<Item = ExtrinsicFor<B>>
) -> Result<Vec<Result<ExtrinsicHash<B>, B::Error>>, B::Error>
pub async fn submit_at(
&self,
at: &BlockId<B::Block>,
source: TransactionSource,
xts: impl IntoIterator<Item = ExtrinsicFor<B>>
) -> Result<Vec<Result<ExtrinsicHash<B>, B::Error>>, B::Error>
Imports a bunch of unverified extrinsics to the pool
sourcepub async fn resubmit_at(
&self,
at: &BlockId<B::Block>,
source: TransactionSource,
xts: impl IntoIterator<Item = ExtrinsicFor<B>>
) -> Result<Vec<Result<ExtrinsicHash<B>, B::Error>>, B::Error>
pub async fn resubmit_at(
&self,
at: &BlockId<B::Block>,
source: TransactionSource,
xts: impl IntoIterator<Item = ExtrinsicFor<B>>
) -> Result<Vec<Result<ExtrinsicHash<B>, 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: &BlockId<B::Block>,
source: TransactionSource,
xt: ExtrinsicFor<B>
) -> Result<ExtrinsicHash<B>, B::Error>
pub async fn submit_one(
&self,
at: &BlockId<B::Block>,
source: TransactionSource,
xt: ExtrinsicFor<B>
) -> Result<ExtrinsicHash<B>, B::Error>
Imports one unverified extrinsic to the pool
sourcepub async fn submit_and_watch(
&self,
at: &BlockId<B::Block>,
source: TransactionSource,
xt: ExtrinsicFor<B>
) -> Result<Watcher<ExtrinsicHash<B>, ExtrinsicHash<B>>, B::Error>
pub async fn submit_and_watch(
&self,
at: &BlockId<B::Block>,
source: TransactionSource,
xt: ExtrinsicFor<B>
) -> Result<Watcher<ExtrinsicHash<B>, ExtrinsicHash<B>>, B::Error>
Import a single extrinsic and starts to watch their progress in the pool.
sourcepub fn resubmit(
&self,
revalidated_transactions: HashMap<ExtrinsicHash<B>, ValidatedTransaction<ExtrinsicHash<B>, ExtrinsicFor<B>, <B as ChainApi>::Error>>
)
pub fn resubmit(
&self,
revalidated_transactions: HashMap<ExtrinsicHash<B>, ValidatedTransaction<ExtrinsicHash<B>, ExtrinsicFor<B>, <B as ChainApi>::Error>>
)
Resubmit some transaction that were validated elsewhere.
sourcepub fn prune_known(
&self,
at: &BlockId<B::Block>,
hashes: &[ExtrinsicHash<B>]
) -> Result<(), B::Error>
pub fn prune_known(
&self,
at: &BlockId<B::Block>,
hashes: &[ExtrinsicHash<B>]
) -> 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: &BlockId<B::Block>,
parent: &BlockId<B::Block>,
extrinsics: &[ExtrinsicFor<B>]
) -> Result<(), B::Error>
pub async fn prune(
&self,
at: &BlockId<B::Block>,
parent: &BlockId<B::Block>,
extrinsics: &[ExtrinsicFor<B>]
) -> 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: &ExtrinsicFor<B>) -> ExtrinsicHash<B>
pub fn hash_of(&self, xt: &ExtrinsicFor<B>) -> ExtrinsicHash<B>
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
sourceimpl<B: ChainApi> MallocSizeOf for Pool<B> where
ExtrinsicFor<B>: MallocSizeOf,
impl<B: ChainApi> MallocSizeOf for Pool<B> where
ExtrinsicFor<B>: MallocSizeOf,
sourcefn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
If T::size_of
is a constant, consider implementing constant_size
as well. Read more
sourcefn constant_size() -> Option<usize>
fn constant_size() -> Option<usize>
Used to optimize MallocSizeOf
implementation for collections
like Vec
and HashMap
to avoid iterating over them unnecessarily.
The Self: Sized
bound is for object safety. 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedConversion for T
impl<T> CheckedConversion for T
sourcefn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
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
sourcefn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
Consume self to return Some
equivalent value of Option<T>
. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<T> MallocSizeOfExt for T where
T: MallocSizeOf,
impl<T> MallocSizeOfExt for T where
T: MallocSizeOf,
sourcefn malloc_size_of(&self) -> usize
fn malloc_size_of(&self) -> usize
Method to launch a heapsize measurement with a fresh state. Read more
sourceimpl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
sourcefn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
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
sourcefn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of T
. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.
sourceimpl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
sourcepub fn unique_saturated_into(self) -> T
pub fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of T
.
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more