Trait sc_rpc_api::chain::ChainApiServer

source ·
pub trait ChainApiServer<Number, Hash, Header, Block: Encode>: Sized + Send + Sync + 'static {
    // Required methods
    fn header(&self, hash: Option<Hash>) -> RpcResult<Option<Header>>;
    fn block(&self, hash: Option<Hash>) -> RpcResult<Option<SignedBlock<Block>>>;
    fn block_hash(
        &self,
        hash: Option<ListOrValue<NumberOrHex>>,
    ) -> RpcResult<ListOrValue<Option<Hash>>>;
    fn finalized_head(&self) -> RpcResult<Hash>;
    fn subscribe_all_heads(
        &self,
        subscription_sink: SubscriptionSink,
    ) -> SubscriptionResult;
    fn subscribe_new_heads(
        &self,
        subscription_sink: SubscriptionSink,
    ) -> SubscriptionResult;
    fn subscribe_finalized_heads(
        &self,
        subscription_sink: SubscriptionSink,
    ) -> SubscriptionResult;

    // Provided methods
    fn block_bin(&self, hash: Option<Hash>) -> RpcResult<Option<String>> { ... }
    fn into_rpc(self) -> RpcModule<Self>
       where Number: Send + Sync + 'static,
             Hash: Send + Sync + 'static + DeserializeOwned + Serialize,
             Header: Send + Sync + 'static + Serialize,
             Block: Send + Sync + 'static + Serialize { ... }
}
Expand description

Server trait implementation for the ChainApi RPC API.

Required Methods§

source

fn header(&self, hash: Option<Hash>) -> RpcResult<Option<Header>>

Get header.

source

fn block(&self, hash: Option<Hash>) -> RpcResult<Option<SignedBlock<Block>>>

Get header and body of a block.

source

fn block_hash( &self, hash: Option<ListOrValue<NumberOrHex>>, ) -> RpcResult<ListOrValue<Option<Hash>>>

Get hash of the n-th block in the canon chain.

By default returns latest block hash.

source

fn finalized_head(&self) -> RpcResult<Hash>

Get hash of the last finalized block in the canon chain.

source

fn subscribe_all_heads( &self, subscription_sink: SubscriptionSink, ) -> SubscriptionResult

All head subscription.

source

fn subscribe_new_heads( &self, subscription_sink: SubscriptionSink, ) -> SubscriptionResult

New head subscription.

source

fn subscribe_finalized_heads( &self, subscription_sink: SubscriptionSink, ) -> SubscriptionResult

Finalized head subscription.

Provided Methods§

source

fn block_bin(&self, hash: Option<Hash>) -> RpcResult<Option<String>>

Get a hex-encoded block.

source

fn into_rpc(self) -> RpcModule<Self>
where Number: Send + Sync + 'static, Hash: Send + Sync + 'static + DeserializeOwned + Serialize, Header: Send + Sync + 'static + Serialize, Block: Send + Sync + 'static + Serialize,

Collects all the methods and subscriptions defined in the trait and adds them into a single RpcModule.

Object Safety§

This trait is not object safe.

Implementors§