pub struct ForkAwareTxPool<ChainApi, Block>{ /* private fields */ }
Expand description
The fork-aware transaction pool.
It keeps track of every fork and provides the set of transactions that is valid for every fork.
Implementations§
Source§impl<ChainApi, Block> ForkAwareTxPool<ChainApi, Block>
impl<ChainApi, Block> ForkAwareTxPool<ChainApi, Block>
Sourcepub fn new_test(
pool_api: Arc<ChainApi>,
best_block_hash: Block::Hash,
finalized_hash: Block::Hash,
) -> (Self, ForkAwareTxPoolTask)
pub fn new_test( pool_api: Arc<ChainApi>, best_block_hash: Block::Hash, finalized_hash: Block::Hash, ) -> (Self, ForkAwareTxPoolTask)
Create new fork aware transaction pool with provided shared instance of ChainApi
intended
for tests.
Sourcepub fn new_test_with_limits(
pool_api: Arc<ChainApi>,
best_block_hash: Block::Hash,
finalized_hash: Block::Hash,
ready_limits: PoolLimit,
future_limits: PoolLimit,
mempool_max_transactions_count: usize,
) -> (Self, ForkAwareTxPoolTask)
pub fn new_test_with_limits( pool_api: Arc<ChainApi>, best_block_hash: Block::Hash, finalized_hash: Block::Hash, ready_limits: PoolLimit, future_limits: PoolLimit, mempool_max_transactions_count: usize, ) -> (Self, ForkAwareTxPoolTask)
Create new fork aware transaction pool with given limits and with provided shared instance
of ChainApi
intended for tests.
Sourcepub fn new_with_background_worker(
options: Options,
is_validator: IsValidator,
pool_api: Arc<ChainApi>,
prometheus: Option<&PrometheusRegistry>,
spawner: impl SpawnEssentialNamed,
best_block_hash: Block::Hash,
finalized_hash: Block::Hash,
) -> Self
pub fn new_with_background_worker( options: Options, is_validator: IsValidator, pool_api: Arc<ChainApi>, prometheus: Option<&PrometheusRegistry>, spawner: impl SpawnEssentialNamed, best_block_hash: Block::Hash, finalized_hash: Block::Hash, ) -> Self
Creates new fork aware transaction pool with the background revalidation worker.
The txpool essential tasks (including a revalidation worker) are spawned using provided spawner.
Sourcepub fn status_all(&self) -> HashMap<Block::Hash, PoolStatus>
pub fn status_all(&self) -> HashMap<Block::Hash, PoolStatus>
Provides a status for all views at the tips of the forks.
Sourcepub fn active_views_count(&self) -> usize
pub fn active_views_count(&self) -> usize
Provides a number of views at the tips of the forks.
Sourcepub fn inactive_views_count(&self) -> usize
pub fn inactive_views_count(&self) -> usize
Provides a number of views at the tips of the forks.
Sourcepub fn has_view(&self, hash: &Block::Hash) -> bool
pub fn has_view(&self, hash: &Block::Hash) -> bool
Checks if there is a view at the tip of the fork with given hash.
Sourcepub fn mempool_len(&self) -> (usize, usize)
pub fn mempool_len(&self) -> (usize, usize)
Returns a number of unwatched and watched transactions in internal mempool.
Intended for use in unit tests.
Sourcepub fn ready_at_light(
&self,
at: Block::Hash,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Transaction<<<ChainApi as ChainApi>::Block as Block>::Hash, Arc<<<ChainApi as ChainApi>::Block as Block>::Extrinsic>>>> + Send>> + Send>>
pub fn ready_at_light( &self, at: Block::Hash, ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Transaction<<<ChainApi as ChainApi>::Block as Block>::Hash, Arc<<<ChainApi as ChainApi>::Block as Block>::Extrinsic>>>> + Send>> + Send>>
Returns a best-effort set of ready transactions for a given block, without executing full maintain process.
The method attempts to build a temporary view and create an iterator of ready transactions
for a specific at
hash. If a valid view is found, it collects and prunes
transactions already included in the blocks and returns the valid set.
Pruning is just rebuilding the underlying transactions graph, no validations are executed, so this process shall be fast.
Source§impl<Block, Client> ForkAwareTxPool<FullChainApi<Client, Block>, Block>where
Block: BlockT,
Client: ProvideRuntimeApi<Block> + BlockBackend<Block> + HeaderBackend<Block> + BlockIdTo<Block> + ExecutorProvider<Block> + UsageProvider<Block> + HeaderMetadata<Block, Error = Error> + Send + Sync + 'static,
Client::Api: TaggedTransactionQueue<Block>,
<Block as BlockT>::Hash: Unpin,
impl<Block, Client> ForkAwareTxPool<FullChainApi<Client, Block>, Block>where
Block: BlockT,
Client: ProvideRuntimeApi<Block> + BlockBackend<Block> + HeaderBackend<Block> + BlockIdTo<Block> + ExecutorProvider<Block> + UsageProvider<Block> + HeaderMetadata<Block, Error = Error> + Send + Sync + 'static,
Client::Api: TaggedTransactionQueue<Block>,
<Block as BlockT>::Hash: Unpin,
Sourcepub fn new_full(
options: Options,
is_validator: IsValidator,
prometheus: Option<&PrometheusRegistry>,
spawner: impl SpawnEssentialNamed,
client: Arc<Client>,
) -> Self
pub fn new_full( options: Options, is_validator: IsValidator, prometheus: Option<&PrometheusRegistry>, spawner: impl SpawnEssentialNamed, client: Arc<Client>, ) -> Self
Create new fork aware transaction pool for a full node with the provided api.
Trait Implementations§
Source§impl<Block, Client> LocalTransactionPool for ForkAwareTxPool<FullChainApi<Client, Block>, Block>where
Block: BlockT,
<Block as BlockT>::Hash: Unpin,
Client: ProvideRuntimeApi<Block> + BlockBackend<Block> + HeaderBackend<Block> + BlockIdTo<Block> + HeaderMetadata<Block, Error = Error> + Send + Sync + 'static,
Client::Api: TaggedTransactionQueue<Block>,
impl<Block, Client> LocalTransactionPool for ForkAwareTxPool<FullChainApi<Client, Block>, Block>where
Block: BlockT,
<Block as BlockT>::Hash: Unpin,
Client: ProvideRuntimeApi<Block> + BlockBackend<Block> + HeaderBackend<Block> + BlockIdTo<Block> + HeaderMetadata<Block, Error = Error> + Send + Sync + 'static,
Client::Api: TaggedTransactionQueue<Block>,
Source§type Hash = <<FullChainApi<Client, Block> as ChainApi>::Block as Block>::Hash
type Hash = <<FullChainApi<Client, Block> as ChainApi>::Block as Block>::Hash
Source§fn submit_local(
&self,
_at: Block::Hash,
xt: LocalTransactionFor<Self>,
) -> Result<Self::Hash, Self::Error>
fn submit_local( &self, _at: Block::Hash, xt: LocalTransactionFor<Self>, ) -> Result<Self::Hash, Self::Error>
TransactionSource::Local
.Source§impl<ChainApi, Block> MaintainedTransactionPool for ForkAwareTxPool<ChainApi, Block>
impl<ChainApi, Block> MaintainedTransactionPool for ForkAwareTxPool<ChainApi, Block>
Source§impl<ChainApi, Block> TransactionPool for ForkAwareTxPool<ChainApi, Block>
impl<ChainApi, Block> TransactionPool for ForkAwareTxPool<ChainApi, Block>
Source§fn submit_at(
&self,
_: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xts: Vec<TransactionFor<Self>>,
) -> PoolFuture<Vec<Result<TxHash<Self>, Self::Error>>, Self::Error>
fn submit_at( &self, _: <Self::Block as BlockT>::Hash, source: TransactionSource, xts: Vec<TransactionFor<Self>>, ) -> PoolFuture<Vec<Result<TxHash<Self>, Self::Error>>, Self::Error>
Submits multiple transactions and returns a future resolving to the submission results.
Actual transactions submission process is delegated to the ViewStore
internal instance.
The internal limits of the pool are checked. The results of submissions to individual views
are reduced to single result. Refer to reduce_multiview_result
for more details.
Source§fn submit_one(
&self,
_at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xt: TransactionFor<Self>,
) -> PoolFuture<TxHash<Self>, Self::Error>
fn submit_one( &self, _at: <Self::Block as BlockT>::Hash, source: TransactionSource, xt: TransactionFor<Self>, ) -> PoolFuture<TxHash<Self>, Self::Error>
Submits a single transaction and returns a future resolving to the submission results.
Actual transaction submission process is delegated to the submit_at
function.
Source§fn submit_and_watch(
&self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xt: TransactionFor<Self>,
) -> PoolFuture<Pin<Box<TransactionStatusStreamFor<Self>>>, Self::Error>
fn submit_and_watch( &self, at: <Self::Block as BlockT>::Hash, source: TransactionSource, xt: TransactionFor<Self>, ) -> PoolFuture<Pin<Box<TransactionStatusStreamFor<Self>>>, Self::Error>
Submits a transaction and starts to watch its progress in the pool, returning a stream of status updates.
Actual transaction submission process is delegated to the ViewStore
internal instance.
Source§fn remove_invalid(
&self,
hashes: &[TxHash<Self>],
) -> Vec<Arc<Self::InPoolTransaction>>
fn remove_invalid( &self, hashes: &[TxHash<Self>], ) -> Vec<Arc<Self::InPoolTransaction>>
Intended to remove transactions identified by the given hashes, and any dependent transactions, from the pool. In current implementation this function only outputs the error. Seems that API change is needed here to make this call reasonable.
Source§fn status(&self) -> PoolStatus
fn status(&self) -> PoolStatus
Returns the pool status which includes information like the number of ready and future transactions.
Currently the status for the most recently notified best block is returned (for which maintain process was accomplished).
Source§fn import_notification_stream(
&self,
) -> ImportNotificationStream<<<ChainApi as ChainApi>::Block as Block>::Hash>
fn import_notification_stream( &self, ) -> ImportNotificationStream<<<ChainApi as ChainApi>::Block as Block>::Hash>
Return an event stream of notifications when transactions are imported to the pool.
Consumers of this stream should use the ready
method to actually get the
pending transactions in the right order.
Source§fn hash_of(&self, xt: &TransactionFor<Self>) -> TxHash<Self>
fn hash_of(&self, xt: &TransactionFor<Self>) -> TxHash<Self>
Returns the hash of a given transaction.
Source§fn on_broadcasted(&self, propagations: HashMap<TxHash<Self>, Vec<String>>)
fn on_broadcasted(&self, propagations: HashMap<TxHash<Self>, Vec<String>>)
Notifies the pool about the broadcasting status of transactions.
Source§fn ready_transaction(
&self,
tx_hash: &TxHash<Self>,
) -> Option<Arc<Self::InPoolTransaction>>
fn ready_transaction( &self, tx_hash: &TxHash<Self>, ) -> Option<Arc<Self::InPoolTransaction>>
Return specific ready transaction by hash, if there is one.
Currently the ready transaction is returned if it exists for the most recently notified best block (for which maintain process was accomplished).
Source§fn ready_at(
&self,
at: <Self::Block as BlockT>::Hash,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Transaction<<<ChainApi as ChainApi>::Block as Block>::Hash, Arc<<<ChainApi as ChainApi>::Block as Block>::Extrinsic>>>> + Send>> + Send>>
fn ready_at( &self, at: <Self::Block as BlockT>::Hash, ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Transaction<<<ChainApi as ChainApi>::Block as Block>::Hash, Arc<<<ChainApi as ChainApi>::Block as Block>::Extrinsic>>>> + Send>> + Send>>
Returns an iterator for ready transactions at a specific block, ordered by priority.
Source§fn ready(
&self,
) -> Box<dyn ReadyTransactions<Item = Arc<Transaction<<<ChainApi as ChainApi>::Block as Block>::Hash, Arc<<<ChainApi as ChainApi>::Block as Block>::Extrinsic>>>> + Send>
fn ready( &self, ) -> Box<dyn ReadyTransactions<Item = Arc<Transaction<<<ChainApi as ChainApi>::Block as Block>::Hash, Arc<<<ChainApi as ChainApi>::Block as Block>::Extrinsic>>>> + Send>
Returns an iterator for ready transactions, ordered by priority.
Currently the set of ready transactions is returned if it exists for the most recently notified best block (for which maintain process was accomplished).
Source§fn futures(&self) -> Vec<Self::InPoolTransaction>
fn futures(&self) -> Vec<Self::InPoolTransaction>
Returns a list of future transactions in the pool.
Currently the set of future transactions is returned if it exists for the most recently notified best block (for which maintain process was accomplished).
Source§fn ready_at_with_timeout(
&self,
at: <Self::Block as BlockT>::Hash,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Transaction<<<ChainApi as ChainApi>::Block as Block>::Hash, Arc<<<ChainApi as ChainApi>::Block as Block>::Extrinsic>>>> + Send>> + Send>>
fn ready_at_with_timeout( &self, at: <Self::Block as BlockT>::Hash, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Transaction<<<ChainApi as ChainApi>::Block as Block>::Hash, Arc<<<ChainApi as ChainApi>::Block as Block>::Extrinsic>>>> + Send>> + Send>>
Returns a set of ready transactions at a given block within the specified timeout.
If the timeout expires before the maintain process is accomplished, a best-effort
set of transactions is returned (refer to ready_at_light
).
Auto Trait Implementations§
impl<ChainApi, Block> Freeze for ForkAwareTxPool<ChainApi, Block>
impl<ChainApi, Block> !RefUnwindSafe for ForkAwareTxPool<ChainApi, Block>
impl<ChainApi, Block> Send for ForkAwareTxPool<ChainApi, Block>
impl<ChainApi, Block> Sync for ForkAwareTxPool<ChainApi, Block>
impl<ChainApi, Block> Unpin for ForkAwareTxPool<ChainApi, Block>
impl<ChainApi, Block> !UnwindSafe for ForkAwareTxPool<ChainApi, Block>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§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 S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.