pub trait TransactionPool: Send + Sync {
type Block: BlockT;
type Hash: Hash + Eq + Member + Serialize + DeserializeOwned + Codec;
type InPoolTransaction: InPoolTransaction<Transaction = Arc<TransactionFor<Self>>, Hash = TxHash<Self>>;
type Error: From<Error> + IntoPoolError;
Show 13 methods
// Required methods
fn submit_at<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xts: Vec<TransactionFor<Self>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Result<TxHash<Self>, Self::Error>>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn submit_one<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xt: TransactionFor<Self>,
) -> Pin<Box<dyn Future<Output = Result<TxHash<Self>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn submit_and_watch<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xt: TransactionFor<Self>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<TransactionStatusStreamFor<Self>>>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ready_at<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ready(
&self,
) -> Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>;
fn report_invalid(
&self,
at: Option<<Self::Block as BlockT>::Hash>,
invalid_tx_errors: TxInvalidityReportMap<TxHash<Self>>,
) -> Vec<Arc<Self::InPoolTransaction>>;
fn futures(&self) -> Vec<Self::InPoolTransaction>;
fn status(&self) -> PoolStatus;
fn import_notification_stream(
&self,
) -> ImportNotificationStream<TxHash<Self>>;
fn on_broadcasted(&self, propagations: HashMap<TxHash<Self>, Vec<String>>);
fn hash_of(&self, xt: &TransactionFor<Self>) -> TxHash<Self>;
fn ready_transaction(
&self,
hash: &TxHash<Self>,
) -> Option<Arc<Self::InPoolTransaction>>;
fn ready_at_with_timeout<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Transaction pool interface.
Required Associated Types§
Sourcetype InPoolTransaction: InPoolTransaction<Transaction = Arc<TransactionFor<Self>>, Hash = TxHash<Self>>
type InPoolTransaction: InPoolTransaction<Transaction = Arc<TransactionFor<Self>>, Hash = TxHash<Self>>
In-pool transaction type.
Sourcetype Error: From<Error> + IntoPoolError
type Error: From<Error> + IntoPoolError
Error type.
Required Methods§
Sourcefn submit_at<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xts: Vec<TransactionFor<Self>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Result<TxHash<Self>, Self::Error>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn submit_at<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xts: Vec<TransactionFor<Self>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Result<TxHash<Self>, Self::Error>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Asynchronously imports a bunch of unverified transactions to the pool.
Sourcefn submit_one<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xt: TransactionFor<Self>,
) -> Pin<Box<dyn Future<Output = Result<TxHash<Self>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn submit_one<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xt: TransactionFor<Self>,
) -> Pin<Box<dyn Future<Output = Result<TxHash<Self>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Asynchronously imports one unverified transaction to the pool.
Sourcefn submit_and_watch<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xt: TransactionFor<Self>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<TransactionStatusStreamFor<Self>>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn submit_and_watch<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xt: TransactionFor<Self>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<TransactionStatusStreamFor<Self>>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Asynchronously imports a single transaction and starts to watch their progress in the pool.
Sourcefn ready_at<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ready_at<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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.
Sourcefn ready(
&self,
) -> Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>
fn ready( &self, ) -> Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>
Get an iterator for ready transactions ordered by priority.
Sourcefn report_invalid(
&self,
at: Option<<Self::Block as BlockT>::Hash>,
invalid_tx_errors: TxInvalidityReportMap<TxHash<Self>>,
) -> Vec<Arc<Self::InPoolTransaction>>
fn report_invalid( &self, at: Option<<Self::Block as BlockT>::Hash>, invalid_tx_errors: TxInvalidityReportMap<TxHash<Self>>, ) -> Vec<Arc<Self::InPoolTransaction>>
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.
Sourcefn futures(&self) -> Vec<Self::InPoolTransaction>
fn futures(&self) -> Vec<Self::InPoolTransaction>
Get futures transaction list.
Sourcefn status(&self) -> PoolStatus
fn status(&self) -> PoolStatus
Returns pool status.
Sourcefn import_notification_stream(&self) -> ImportNotificationStream<TxHash<Self>>
fn import_notification_stream(&self) -> ImportNotificationStream<TxHash<Self>>
Return an event stream of transactions imported to the pool.
Sourcefn on_broadcasted(&self, propagations: HashMap<TxHash<Self>, Vec<String>>)
fn on_broadcasted(&self, propagations: HashMap<TxHash<Self>, Vec<String>>)
Notify the pool about transactions broadcast.
Sourcefn hash_of(&self, xt: &TransactionFor<Self>) -> TxHash<Self>
fn hash_of(&self, xt: &TransactionFor<Self>) -> TxHash<Self>
Returns transaction hash
Sourcefn ready_transaction(
&self,
hash: &TxHash<Self>,
) -> Option<Arc<Self::InPoolTransaction>>
fn ready_transaction( &self, hash: &TxHash<Self>, ) -> Option<Arc<Self::InPoolTransaction>>
Return specific ready transaction by hash, if there is one.
Sourcefn ready_at_with_timeout<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ready_at_with_timeout<'life0, 'async_trait>(
&'life0 self,
at: <Self::Block as BlockT>::Hash,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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.