Skip to main content

TransactionPool

Trait TransactionPool 

Source
pub trait TransactionPool: Send + Sync {
    type Block: Block;
    type Hash: Hash + Eq + Member + Serialize + DeserializeOwned + Codec;
    type InPoolTransaction: InPoolTransaction<Transaction = Arc<<Self::Block as Block>::Extrinsic>, Hash = Self::Hash>;
    type Error: From<Error> + IntoPoolError;

Show 13 methods // Required methods fn submit_at<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, source: TransactionSource, xts: Vec<<Self::Block as Block>::Extrinsic>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<Self::Hash, Self::Error>>, Self::Error>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn submit_one<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, source: TransactionSource, xt: <Self::Block as Block>::Extrinsic, ) -> Pin<Box<dyn Future<Output = Result<Self::Hash, Self::Error>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn submit_and_watch<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, source: TransactionSource, xt: <Self::Block as Block>::Extrinsic, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = TransactionStatus<Self::Hash, <Self::Block as Block>::Hash>> + Send>>, Self::Error>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn ready_at<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn ready( &self, ) -> Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>; fn report_invalid<'life0, 'async_trait>( &'life0 self, at: Option<<Self::Block as Block>::Hash>, invalid_tx_errors: IndexMap<Self::Hash, Option<TransactionValidityError>>, ) -> Pin<Box<dyn Future<Output = Vec<Arc<Self::InPoolTransaction>>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn futures(&self) -> Vec<Self::InPoolTransaction>; fn status(&self) -> PoolStatus; fn import_notification_stream(&self) -> Receiver<Self::Hash>; fn on_broadcasted(&self, propagations: HashMap<Self::Hash, Vec<String>>); fn hash_of(&self, xt: &<Self::Block as Block>::Extrinsic) -> Self::Hash; fn ready_transaction( &self, hash: &Self::Hash, ) -> Option<Arc<Self::InPoolTransaction>>; fn ready_at_with_timeout<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait;
}
Expand description

Transaction pool interface.

Required Associated Types§

Source

type Block: Block

Block type.

Source

type Hash: Hash + Eq + Member + Serialize + DeserializeOwned + Codec

Transaction hash type.

Source

type InPoolTransaction: InPoolTransaction<Transaction = Arc<<Self::Block as Block>::Extrinsic>, Hash = Self::Hash>

In-pool transaction type.

Source

type Error: From<Error> + IntoPoolError

Error type.

Required Methods§

Source

fn submit_at<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, source: TransactionSource, xts: Vec<<Self::Block as Block>::Extrinsic>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<Self::Hash, Self::Error>>, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Asynchronously imports a bunch of unverified transactions to the pool.

Source

fn submit_one<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, source: TransactionSource, xt: <Self::Block as Block>::Extrinsic, ) -> Pin<Box<dyn Future<Output = Result<Self::Hash, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Asynchronously imports one unverified transaction to the pool.

Source

fn submit_and_watch<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, source: TransactionSource, xt: <Self::Block as Block>::Extrinsic, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = TransactionStatus<Self::Hash, <Self::Block as Block>::Hash>> + Send>>, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Asynchronously imports a single transaction and starts to watch their progress in the pool.

Source

fn ready_at<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Get an iterator for ready transactions ordered by priority.

Guaranteed to resolve only when transaction pool got updated at at block. Guaranteed to resolve immediately when None is passed.

Source

fn ready( &self, ) -> Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>

Get an iterator for ready transactions ordered by priority.

Source

fn report_invalid<'life0, 'async_trait>( &'life0 self, at: Option<<Self::Block as Block>::Hash>, invalid_tx_errors: IndexMap<Self::Hash, Option<TransactionValidityError>>, ) -> Pin<Box<dyn Future<Output = Vec<Arc<Self::InPoolTransaction>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Reports invalid transactions to the transaction pool.

This function takes a map where the key is a transaction hash and the value is an optional error encountered during the transaction execution, possibly within a specific block.

The transaction pool implementation decides which transactions to remove. Transactions removed from the pool will be notified with TransactionStatus::Invalid event (if submit_and_watch was used for submission).

If the error associated to transaction is None, the transaction will be forcibly removed from the pool.

The optional at parameter provides additional context regarding the block where the error occurred.

Function returns the transactions actually removed from the pool.

Source

fn futures(&self) -> Vec<Self::InPoolTransaction>

Get futures transaction list.

Source

fn status(&self) -> PoolStatus

Returns pool status.

Source

fn import_notification_stream(&self) -> Receiver<Self::Hash>

Return an event stream of transactions imported to the pool.

Source

fn on_broadcasted(&self, propagations: HashMap<Self::Hash, Vec<String>>)

Notify the pool about transactions broadcast.

Source

fn hash_of(&self, xt: &<Self::Block as Block>::Extrinsic) -> Self::Hash

Returns transaction hash

Source

fn ready_transaction( &self, hash: &Self::Hash, ) -> Option<Arc<Self::InPoolTransaction>>

Return specific ready transaction by hash, if there is one.

Source

fn ready_at_with_timeout<'life0, 'async_trait>( &'life0 self, at: <Self::Block as Block>::Hash, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Asynchronously returns a set of ready transaction at given block within given timeout.

If the timeout is hit during method execution, then the best effort (without executing full maintain process) set of ready transactions for given block is returned.

Implementors§

Source§

impl<Block, Client> TransactionPool for TransactionPoolWrapper<Block, Client>
where Block: Block, Client: ProvideRuntimeApi<Block> + BlockBackend<Block> + HeaderBackend<Block> + BlockIdTo<Block> + HeaderMetadata<Block, Error = Error> + 'static, <Client as ProvideRuntimeApi<Block>>::Api: TaggedTransactionQueue<Block>,

Source§

type Block = Block

Source§

type Hash = <<FullChainApi<Client, Block> as ChainApi>::Block as Block>::Hash

Source§

type InPoolTransaction = Transaction<<<FullChainApi<Client, Block> as ChainApi>::Block as Block>::Hash, Arc<<<FullChainApi<Client, Block> as ChainApi>::Block as Block>::Extrinsic>>

Source§

type Error = <FullChainApi<Client, Block> as ChainApi>::Error

Source§

impl<ChainApi, Block> TransactionPool for ForkAwareTxPool<ChainApi, Block>
where Block: Block, ChainApi: 'static + ChainApi<Block = Block>, <Block as Block>::Hash: Unpin,

Source§

type Block = <ChainApi as ChainApi>::Block

Source§

type Hash = <<ChainApi as ChainApi>::Block as Block>::Hash

Source§

type InPoolTransaction = Transaction<<<ChainApi as ChainApi>::Block as Block>::Hash, Arc<<<ChainApi as ChainApi>::Block as Block>::Extrinsic>>

Source§

type Error = <ChainApi as ChainApi>::Error

Source§

impl<PoolApi, Block> TransactionPool for BasicPool<PoolApi, Block>
where Block: Block, PoolApi: 'static + ChainApi<Block = Block>,

Source§

type Block = <PoolApi as ChainApi>::Block

Source§

type Hash = <<PoolApi as ChainApi>::Block as Block>::Hash

Source§

type InPoolTransaction = Transaction<<<PoolApi as ChainApi>::Block as Block>::Hash, Arc<<<PoolApi as ChainApi>::Block as Block>::Extrinsic>>

Source§

type Error = <PoolApi as ChainApi>::Error