pub trait TransactionPool: Send + Sync {
type Block: BlockT;
type Hash: Hash + Eq + Member + Serialize + DeserializeOwned + Codec;
type InPoolTransaction: InPoolTransaction<Transaction = TransactionFor<Self>, Hash = TxHash<Self>>;
type Error: From<Error> + IntoPoolError;
// Required methods
fn submit_at(
&self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xts: Vec<TransactionFor<Self>>,
) -> PoolFuture<Vec<Result<TxHash<Self>, Self::Error>>, Self::Error>;
fn submit_one(
&self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xt: TransactionFor<Self>,
) -> PoolFuture<TxHash<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>;
fn ready_at(
&self,
at: NumberFor<Self::Block>,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send>>;
fn ready(
&self,
) -> Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>;
fn remove_invalid(
&self,
hashes: &[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>>;
}
Expand description
Transaction pool interface.
Required Associated Types§
sourcetype InPoolTransaction: InPoolTransaction<Transaction = TransactionFor<Self>, Hash = TxHash<Self>>
type InPoolTransaction: InPoolTransaction<Transaction = 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(
&self,
at: <Self::Block as BlockT>::Hash,
source: TransactionSource,
xts: Vec<TransactionFor<Self>>,
) -> PoolFuture<Vec<Result<TxHash<Self>, Self::Error>>, Self::Error>
fn submit_at( &self, at: <Self::Block as BlockT>::Hash, source: TransactionSource, xts: Vec<TransactionFor<Self>>, ) -> PoolFuture<Vec<Result<TxHash<Self>, Self::Error>>, Self::Error>
Returns a future that imports a bunch of unverified transactions to the pool.
sourcefn 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>
Returns a future that imports one unverified transaction to the pool.
sourcefn 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>
Returns a future that import a single transaction and starts to watch their progress in the pool.
sourcefn ready_at(
&self,
at: NumberFor<Self::Block>,
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send>>
fn ready_at( &self, at: NumberFor<Self::Block>, ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>> + Send>>
Get an iterator for ready transactions ordered by priority.
Guarantees to return only when transaction pool got updated at at
block.
Guarantees to return 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 remove_invalid(
&self,
hashes: &[TxHash<Self>],
) -> Vec<Arc<Self::InPoolTransaction>>
fn remove_invalid( &self, hashes: &[TxHash<Self>], ) -> Vec<Arc<Self::InPoolTransaction>>
Remove transactions identified by given hashes (and dependent transactions) 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.