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: &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>
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
sourcepub 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>
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.
sourcepub 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>
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
sourcepub 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>
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.
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: &BlockId<B::Block>,
parent: &BlockId<B::Block>,
extrinsics: &[<<B as ChainApi>::Block as Block>::Extrinsic]
) -> Result<(), B::Error>
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.
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> !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> CheckedConversion for T
impl<T> CheckedConversion for T
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, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§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<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 Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.