Trait sc_service::TransactionPool

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

    // Required methods
    fn submit_at(
        &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>>;
    fn submit_one(
        &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>>;
    fn submit_and_watch(
        &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>>;
    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>> + Send>>;
    fn ready(
        &self
    ) -> Box<dyn ReadyTransactions<Item = Arc<Self::InPoolTransaction>> + Send>;
    fn remove_invalid(
        &self,
        hashes: &[Self::Hash]
    ) -> Vec<Arc<Self::InPoolTransaction>>;
    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>>;
}
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 = <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( &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>>

Returns a future that imports a bunch of unverified transactions to the pool.

source

fn submit_one( &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>>

Returns a future that imports one unverified transaction to the pool.

source

fn submit_and_watch( &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>>

Returns a future that import a single transaction and starts to watch their progress in the pool.

source

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>> + 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.

source

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

Get an iterator for ready transactions ordered by priority.

source

fn remove_invalid( &self, hashes: &[Self::Hash] ) -> Vec<Arc<Self::InPoolTransaction>>

Remove transactions identified by given hashes (and dependent transactions) 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.

Implementations on Foreign Types§

source§

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

§

type Block = <PoolApi as ChainApi>::Block

§

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

§

type InPoolTransaction = Transaction<<BasicPool<PoolApi, Block> as TransactionPool>::Hash, <<BasicPool<PoolApi, Block> as TransactionPool>::Block as Block>::Extrinsic>

§

type Error = <PoolApi as ChainApi>::Error

source§

fn submit_at( &self, at: <<BasicPool<PoolApi, Block> as TransactionPool>::Block as Block>::Hash, source: TransactionSource, xts: Vec<<<BasicPool<PoolApi, Block> as TransactionPool>::Block as Block>::Extrinsic> ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<<BasicPool<PoolApi, Block> as TransactionPool>::Hash, <BasicPool<PoolApi, Block> as TransactionPool>::Error>>, <BasicPool<PoolApi, Block> as TransactionPool>::Error>> + Send>>

source§

fn submit_one( &self, at: <<BasicPool<PoolApi, Block> as TransactionPool>::Block as Block>::Hash, source: TransactionSource, xt: <<BasicPool<PoolApi, Block> as TransactionPool>::Block as Block>::Extrinsic ) -> Pin<Box<dyn Future<Output = Result<<BasicPool<PoolApi, Block> as TransactionPool>::Hash, <BasicPool<PoolApi, Block> as TransactionPool>::Error>> + Send>>

source§

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

source§

fn remove_invalid( &self, hashes: &[<BasicPool<PoolApi, Block> as TransactionPool>::Hash] ) -> Vec<Arc<<BasicPool<PoolApi, Block> as TransactionPool>::InPoolTransaction>>

source§

fn status(&self) -> PoolStatus

source§

fn import_notification_stream( &self ) -> Receiver<<BasicPool<PoolApi, Block> as TransactionPool>::Hash>

source§

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

source§

fn on_broadcasted( &self, propagations: HashMap<<BasicPool<PoolApi, Block> as TransactionPool>::Hash, Vec<String>> )

source§

fn ready_transaction( &self, hash: &<BasicPool<PoolApi, Block> as TransactionPool>::Hash ) -> Option<Arc<<BasicPool<PoolApi, Block> as TransactionPool>::InPoolTransaction>>

source§

fn ready_at( &self, at: <<<BasicPool<PoolApi, Block> as TransactionPool>::Block as Block>::Header as Header>::Number ) -> Pin<Box<dyn Future<Output = Box<dyn ReadyTransactions<Item = Arc<Transaction<<<PoolApi as ChainApi>::Block as Block>::Hash, <<PoolApi as ChainApi>::Block as Block>::Extrinsic>>> + Send>> + Send>>

source§

fn ready( &self ) -> Box<dyn ReadyTransactions<Item = Arc<Transaction<<<PoolApi as ChainApi>::Block as Block>::Hash, <<PoolApi as ChainApi>::Block as Block>::Extrinsic>>> + Send>

source§

fn futures( &self ) -> Vec<<BasicPool<PoolApi, Block> as TransactionPool>::InPoolTransaction>

Implementors§