Trait sc_service::TransactionPool
source · pub trait TransactionPool: Send + Sync {
type Block: Block;
type Hash: Hash + Eq + Member + Serialize + DeserializeOwned;
type InPoolTransaction: InPoolTransaction<Transaction = <Self::Block as Block>::Extrinsic, Hash = Self::Hash>;
type Error: From<Error> + IntoPoolError;
// Required methods
fn submit_at(
&self,
at: &BlockId<Self::Block>,
source: TransactionSource,
xts: Vec<<Self::Block as Block>::Extrinsic, Global>
) -> Pin<Box<dyn Future<Output = Result<Vec<Result<Self::Hash, Self::Error>, Global>, Self::Error>> + Send + 'static, Global>>;
fn submit_one(
&self,
at: &BlockId<Self::Block>,
source: TransactionSource,
xt: <Self::Block as Block>::Extrinsic
) -> Pin<Box<dyn Future<Output = Result<Self::Hash, Self::Error>> + Send + 'static, Global>>;
fn submit_and_watch(
&self,
at: &BlockId<Self::Block>,
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 + 'static, Global>>, Self::Error>> + Send + 'static, Global>>;
fn ready_at(
&self,
at: <<Self::Block as Block>::Header as Header>::Number
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send + 'static, Global>> + Send + 'static, Global>>;
fn ready(
&self
) -> Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send + 'static, Global>;
fn remove_invalid(
&self,
hashes: &[Self::Hash]
) -> Vec<Arc<Self::InPoolTransaction>, Global>;
fn status(&self) -> PoolStatus;
fn import_notification_stream(&self) -> Receiver<Self::Hash>;
fn on_broadcasted(
&self,
propagations: HashMap<Self::Hash, Vec<String, Global>, RandomState>
);
fn hash_of(&self, xt: &<Self::Block as Block>::Extrinsic) -> Self::Hash;
fn ready_transaction(
&self,
hash: &Self::Hash
) -> Option<Arc<Self::InPoolTransaction>>;
}
Expand description
Transaction pool interface.
Required Associated Types§
sourcetype InPoolTransaction: InPoolTransaction<Transaction = <Self::Block as Block>::Extrinsic, Hash = Self::Hash>
type InPoolTransaction: InPoolTransaction<Transaction = <Self::Block as Block>::Extrinsic, Hash = Self::Hash>
In-pool transaction type.
sourcetype Error: From<Error> + IntoPoolError
type Error: From<Error> + IntoPoolError
Error type.
Required Methods§
sourcefn submit_at(
&self,
at: &BlockId<Self::Block>,
source: TransactionSource,
xts: Vec<<Self::Block as Block>::Extrinsic, Global>
) -> Pin<Box<dyn Future<Output = Result<Vec<Result<Self::Hash, Self::Error>, Global>, Self::Error>> + Send + 'static, Global>>
fn submit_at( &self, at: &BlockId<Self::Block>, source: TransactionSource, xts: Vec<<Self::Block as Block>::Extrinsic, Global> ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<Self::Hash, Self::Error>, Global>, Self::Error>> + Send + 'static, Global>>
Returns a future that imports a bunch of unverified transactions to the pool.
sourcefn submit_one(
&self,
at: &BlockId<Self::Block>,
source: TransactionSource,
xt: <Self::Block as Block>::Extrinsic
) -> Pin<Box<dyn Future<Output = Result<Self::Hash, Self::Error>> + Send + 'static, Global>>
fn submit_one( &self, at: &BlockId<Self::Block>, source: TransactionSource, xt: <Self::Block as Block>::Extrinsic ) -> Pin<Box<dyn Future<Output = Result<Self::Hash, Self::Error>> + Send + 'static, Global>>
Returns a future that imports one unverified transaction to the pool.
sourcefn submit_and_watch(
&self,
at: &BlockId<Self::Block>,
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 + 'static, Global>>, Self::Error>> + Send + 'static, Global>>
fn submit_and_watch( &self, at: &BlockId<Self::Block>, 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 + 'static, Global>>, Self::Error>> + Send + 'static, Global>>
Returns a future that import a single transaction and starts to watch their progress in the pool.
sourcefn ready_at(
&self,
at: <<Self::Block as Block>::Header as Header>::Number
) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send + 'static, Global>> + Send + 'static, Global>>
fn ready_at( &self, at: <<Self::Block as Block>::Header as Header>::Number ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send + 'static, Global>> + Send + 'static, Global>>
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 + 'static, Global>
fn ready( &self ) -> Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send + 'static, Global>
Get an iterator for ready transactions ordered by priority.
sourcefn remove_invalid(
&self,
hashes: &[Self::Hash]
) -> Vec<Arc<Self::InPoolTransaction>, Global>
fn remove_invalid( &self, hashes: &[Self::Hash] ) -> Vec<Arc<Self::InPoolTransaction>, Global>
Remove transactions identified by given hashes (and dependent transactions) from the pool.
sourcefn status(&self) -> PoolStatus
fn status(&self) -> PoolStatus
Returns pool status.
sourcefn import_notification_stream(&self) -> Receiver<Self::Hash>
fn import_notification_stream(&self) -> Receiver<Self::Hash>
Return an event stream of transactions imported to the pool.
sourcefn on_broadcasted(
&self,
propagations: HashMap<Self::Hash, Vec<String, Global>, RandomState>
)
fn on_broadcasted( &self, propagations: HashMap<Self::Hash, Vec<String, Global>, RandomState> )
Notify the pool about transactions broadcast.
sourcefn hash_of(&self, xt: &<Self::Block as Block>::Extrinsic) -> Self::Hash
fn hash_of(&self, xt: &<Self::Block as Block>::Extrinsic) -> Self::Hash
Returns transaction hash
sourcefn ready_transaction(
&self,
hash: &Self::Hash
) -> Option<Arc<Self::InPoolTransaction>>
fn ready_transaction( &self, hash: &Self::Hash ) -> Option<Arc<Self::InPoolTransaction>>
Return specific ready transaction by hash, if there is one.