Struct sc_transaction_graph::base_pool::BasePool
source · [−]Expand description
Transaction pool.
Builds a dependency graph for all transactions in the pool and returns the ones that are currently ready to be executed.
General note: If function returns some transactions it usually means that importing them as-is for the second time will fail or produce unwanted results. Most likely it is required to revalidate them and recompute set of required tags.
Implementations
sourceimpl<Hash: Hash + Member + Serialize, Ex: Debug> BasePool<Hash, Ex>
impl<Hash: Hash + Member + Serialize, Ex: Debug> BasePool<Hash, Ex>
sourcepub fn new(reject_future_transactions: bool) -> Self
pub fn new(reject_future_transactions: bool) -> Self
Create new pool given reject_future_transactions flag.
sourcepub fn is_imported(&self, tx_hash: &Hash) -> bool
pub fn is_imported(&self, tx_hash: &Hash) -> bool
Returns if the transaction for the given hash is already imported.
sourcepub fn import(
&mut self,
tx: Transaction<Hash, Ex>
) -> Result<Imported<Hash, Ex>>
pub fn import(
&mut self,
tx: Transaction<Hash, Ex>
) -> Result<Imported<Hash, Ex>>
Imports transaction to the pool.
The pool consists of two parts: Future and Ready. The former contains transactions that require some tags that are not yet provided by other transactions in the pool. The latter contains transactions that have all the requirements satisfied and are ready to be included in the block.
sourcepub fn ready(&self) -> impl Iterator<Item = Arc<Transaction<Hash, Ex>>>
pub fn ready(&self) -> impl Iterator<Item = Arc<Transaction<Hash, Ex>>>
Returns an iterator over ready transactions in the pool.
sourcepub fn futures(&self) -> impl Iterator<Item = &Transaction<Hash, Ex>>
pub fn futures(&self) -> impl Iterator<Item = &Transaction<Hash, Ex>>
Returns an iterator over future transactions in the pool.
sourcepub fn by_hashes(
&self,
hashes: &[Hash]
) -> Vec<Option<Arc<Transaction<Hash, Ex>>>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn by_hashes(
&self,
hashes: &[Hash]
) -> Vec<Option<Arc<Transaction<Hash, Ex>>>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns pool transactions given list of hashes.
Includes both ready and future pool. For every hash in the hashes
iterator an Option
is produced (so the resulting Vec
always have the same length).
sourcepub fn ready_by_hash(&self, hash: &Hash) -> Option<Arc<Transaction<Hash, Ex>>>
pub fn ready_by_hash(&self, hash: &Hash) -> Option<Arc<Transaction<Hash, Ex>>>
Returns pool transaction by hash.
sourcepub fn enforce_limits(
&mut self,
ready: &Limit,
future: &Limit
) -> Vec<Arc<Transaction<Hash, Ex>>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn enforce_limits(
&mut self,
ready: &Limit,
future: &Limit
) -> Vec<Arc<Transaction<Hash, Ex>>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Makes sure that the transactions in the queues stay within provided limits.
Removes and returns worst transactions from the queues and all transactions that depend on them. Technically the worst transaction should be evaluated by computing the entire pending set. We use a simplified approach to remove the transaction that occupies the pool for the longest time.
sourcepub fn remove_subtree(
&mut self,
hashes: &[Hash]
) -> Vec<Arc<Transaction<Hash, Ex>>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn remove_subtree(
&mut self,
hashes: &[Hash]
) -> Vec<Arc<Transaction<Hash, Ex>>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Removes all transactions represented by the hashes and all other transactions that depend on them.
Returns a list of actually removed transactions.
NOTE some transactions might still be valid, but were just removed because
they were part of a chain, you may attempt to re-import them later.
NOTE If you want to remove ready transactions that were already used
and you don’t want them to be stored in the pool use prune_tags
method.
sourcepub fn clear_future(&mut self) -> Vec<Arc<Transaction<Hash, Ex>>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn clear_future(&mut self) -> Vec<Arc<Transaction<Hash, Ex>>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Removes and returns all transactions from the future queue.
Prunes transactions that provide given list of tags.
This will cause all transactions that provide these tags to be removed from the pool,
but unlike remove_subtree
, dependent transactions are not touched.
Additional transactions from future queue might be promoted to ready if you satisfy tags
that the pool didn’t previously know about.
sourcepub fn status(&self) -> PoolStatus
pub fn status(&self) -> PoolStatus
Get pool status.
Trait Implementations
sourceimpl<Hash: Hash + Eq, Ex> MallocSizeOf for BasePool<Hash, Ex> where
Hash: MallocSizeOf,
Ex: MallocSizeOf,
impl<Hash: Hash + Eq, Ex> MallocSizeOf for BasePool<Hash, Ex> where
Hash: MallocSizeOf,
Ex: 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<Hash, Ex> !RefUnwindSafe for BasePool<Hash, Ex>
impl<Hash, Ex> Send for BasePool<Hash, Ex> where
Ex: Send + Sync,
Hash: Send + Sync,
impl<Hash, Ex> Sync for BasePool<Hash, Ex> where
Ex: Send + Sync,
Hash: Send + Sync,
impl<Hash, Ex> Unpin for BasePool<Hash, Ex> where
Hash: Unpin,
impl<Hash, Ex> !UnwindSafe for BasePool<Hash, Ex>
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<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