referrerpolicy=no-referrer-when-downgrade
sc_rpc::chain

Trait ChainApiServer

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

    // Provided method
    fn into_rpc(self) -> RpcModule<Self>
       where Number: Send + Sync + 'static,
             Hash: Send + Sync + 'static + DeserializeOwned + Clone + Serialize,
             Header: Send + Sync + 'static + Clone + Serialize,
             SignedBlock: Send + Sync + 'static + Clone + Serialize { ... }
}
Expand description

Server trait implementation for the ChainApi RPC API.

Required Methods§

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

Get header.

fn block(&self, hash: Option<Hash>) -> Result<Option<SignedBlock>, Error>

Get header and body of a block.

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

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

By default returns latest block hash.

fn finalized_head(&self) -> Result<Hash, Error>

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

fn subscribe_all_heads(&self, subscription_sink: PendingSubscriptionSink)

All head subscription.

fn subscribe_new_heads(&self, subscription_sink: PendingSubscriptionSink)

New head subscription.

fn subscribe_finalized_heads(&self, subscription_sink: PendingSubscriptionSink)

Finalized head subscription.

Provided Methods§

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

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Block, Client> ChainApiServer<<<Block as Block>::Header as Header>::Number, <Block as Block>::Hash, <Block as Block>::Header, SignedBlock<Block>> for Chain<Block, Client>
where Block: BlockT + 'static, Block::Header: Unpin, Client: HeaderBackend<Block> + BlockchainEvents<Block> + 'static,