referrerpolicy=no-referrer-when-downgrade

Trait sc_transaction_pool::ChainApi

source ·
pub trait ChainApi: Send + Sync {
    type Block: BlockT;
    type Error: From<Error> + IntoPoolError;
    type ValidationFuture: Future<Output = Result<TransactionValidity, Self::Error>> + Send + Unpin;
    type BodyFuture: Future<Output = Result<Option<Vec<<Self::Block as Block>::Extrinsic>>, Self::Error>> + Unpin + Send + 'static;

    // Required methods
    fn validate_transaction(
        &self,
        at: <Self::Block as BlockT>::Hash,
        source: TransactionSource,
        uxt: Arc<<<Self as ChainApi>::Block as Block>::Extrinsic>,
    ) -> Self::ValidationFuture;
    fn validate_transaction_blocking(
        &self,
        at: <Self::Block as BlockT>::Hash,
        source: TransactionSource,
        uxt: Arc<<<Self as ChainApi>::Block as Block>::Extrinsic>,
    ) -> Result<TransactionValidity, Self::Error>;
    fn block_id_to_number(
        &self,
        at: &BlockId<Self::Block>,
    ) -> Result<Option<NumberFor<<Self as ChainApi>::Block>>, Self::Error>;
    fn block_id_to_hash(
        &self,
        at: &BlockId<Self::Block>,
    ) -> Result<Option<<Self::Block as BlockT>::Hash>, Self::Error>;
    fn hash_and_length(
        &self,
        uxt: &<<Self as ChainApi>::Block as Block>::Extrinsic,
    ) -> (<<Self as ChainApi>::Block as Block>::Hash, usize);
    fn block_body(&self, at: <Self::Block as BlockT>::Hash) -> Self::BodyFuture;
    fn block_header(
        &self,
        at: <Self::Block as BlockT>::Hash,
    ) -> Result<Option<<Self::Block as BlockT>::Header>, Self::Error>;
    fn tree_route(
        &self,
        from: <Self::Block as BlockT>::Hash,
        to: <Self::Block as BlockT>::Hash,
    ) -> Result<TreeRoute<Self::Block>, Self::Error>;

    // Provided method
    fn resolve_block_number(
        &self,
        at: <Self::Block as BlockT>::Hash,
    ) -> Result<NumberFor<<Self as ChainApi>::Block>, Self::Error> { ... }
}
Expand description

Concrete extrinsic validation and query logic.

Required Associated Types§

source

type Block: BlockT

Block type.

source

type Error: From<Error> + IntoPoolError

Error type.

source

type ValidationFuture: Future<Output = Result<TransactionValidity, Self::Error>> + Send + Unpin

Validate transaction future.

source

type BodyFuture: Future<Output = Result<Option<Vec<<Self::Block as Block>::Extrinsic>>, Self::Error>> + Unpin + Send + 'static

Body future (since block body might be remote)

Required Methods§

source

fn validate_transaction( &self, at: <Self::Block as BlockT>::Hash, source: TransactionSource, uxt: Arc<<<Self as ChainApi>::Block as Block>::Extrinsic>, ) -> Self::ValidationFuture

Asynchronously verify extrinsic at given block.

source

fn validate_transaction_blocking( &self, at: <Self::Block as BlockT>::Hash, source: TransactionSource, uxt: Arc<<<Self as ChainApi>::Block as Block>::Extrinsic>, ) -> Result<TransactionValidity, Self::Error>

Synchronously verify given extrinsic at given block.

Validates a transaction by calling into the runtime. Same as validate_transaction but blocks the current thread when performing validation.

source

fn block_id_to_number( &self, at: &BlockId<Self::Block>, ) -> Result<Option<NumberFor<<Self as ChainApi>::Block>>, Self::Error>

Returns a block number given the block id.

source

fn block_id_to_hash( &self, at: &BlockId<Self::Block>, ) -> Result<Option<<Self::Block as BlockT>::Hash>, Self::Error>

Returns a block hash given the block id.

source

fn hash_and_length( &self, uxt: &<<Self as ChainApi>::Block as Block>::Extrinsic, ) -> (<<Self as ChainApi>::Block as Block>::Hash, usize)

Returns hash and encoding length of the extrinsic.

source

fn block_body(&self, at: <Self::Block as BlockT>::Hash) -> Self::BodyFuture

Returns a block body given the block.

source

fn block_header( &self, at: <Self::Block as BlockT>::Hash, ) -> Result<Option<<Self::Block as BlockT>::Header>, Self::Error>

Returns a block header given the block id.

source

fn tree_route( &self, from: <Self::Block as BlockT>::Hash, to: <Self::Block as BlockT>::Hash, ) -> Result<TreeRoute<Self::Block>, Self::Error>

Compute a tree-route between two blocks. See [TreeRoute] for more details.

Provided Methods§

source

fn resolve_block_number( &self, at: <Self::Block as BlockT>::Hash, ) -> Result<NumberFor<<Self as ChainApi>::Block>, Self::Error>

Resolves block number by id.

Implementors§

source§

impl<Client, Block> ChainApi for FullChainApi<Client, Block>
where Block: BlockT, Client: ProvideRuntimeApi<Block> + BlockBackend<Block> + BlockIdTo<Block> + HeaderBackend<Block> + HeaderMetadata<Block, Error = Error> + Send + Sync + 'static, Client::Api: TaggedTransactionQueue<Block>,

§

type Block = Block

§

type Error = Error

§

type ValidationFuture = Pin<Box<dyn Future<Output = Result<Result<ValidTransaction, TransactionValidityError>, Error>> + Send>>

§

type BodyFuture = Ready<Result<Option<Vec<<<FullChainApi<Client, Block> as ChainApi>::Block as Block>::Extrinsic>>, Error>>