mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 23:31:07 +00:00
RPC: Mark storage methods as blocking (#11459)
* client/api: Make `storage_keys` blocking Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client/api: Ensure `state_*` RPC methods are blocking Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client/rpc: Ensure `childstate_*` RPC methods are blocking Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client/rpc: `ChainApi` make RPC methods sync Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Remove unused async-traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client/rpc-api: Make chain RPC methods blocking Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update client/rpc/src/state/state_full.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Add `blocking` to `state_getKeysPaged` RPC call Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix build and warning Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Remove `async_trait` tidyup Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -26,7 +26,7 @@ use futures::{
|
||||
future::{self, FutureExt},
|
||||
stream::{self, Stream, StreamExt},
|
||||
};
|
||||
use jsonrpsee::{core::async_trait, PendingSubscription};
|
||||
use jsonrpsee::PendingSubscription;
|
||||
use sc_client_api::{BlockBackend, BlockchainEvents};
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_runtime::{
|
||||
@@ -51,7 +51,6 @@ impl<Block: BlockT, Client> FullChain<Block, Client> {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<Block, Client> ChainBackend<Client, Block> for FullChain<Block, Client>
|
||||
where
|
||||
Block: BlockT + 'static,
|
||||
@@ -62,11 +61,11 @@ where
|
||||
&self.client
|
||||
}
|
||||
|
||||
async fn header(&self, hash: Option<Block::Hash>) -> Result<Option<Block::Header>, Error> {
|
||||
fn header(&self, hash: Option<Block::Hash>) -> Result<Option<Block::Header>, Error> {
|
||||
self.client.header(BlockId::Hash(self.unwrap_or_best(hash))).map_err(client_err)
|
||||
}
|
||||
|
||||
async fn block(&self, hash: Option<Block::Hash>) -> Result<Option<SignedBlock<Block>>, Error> {
|
||||
fn block(&self, hash: Option<Block::Hash>) -> Result<Option<SignedBlock<Block>>, Error> {
|
||||
self.client.block(&BlockId::Hash(self.unwrap_or_best(hash))).map_err(client_err)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,7 @@ use std::sync::Arc;
|
||||
|
||||
use crate::SubscriptionTaskExecutor;
|
||||
|
||||
use jsonrpsee::{
|
||||
core::{async_trait, RpcResult},
|
||||
PendingSubscription,
|
||||
};
|
||||
use jsonrpsee::{core::RpcResult, PendingSubscription};
|
||||
use sc_client_api::BlockchainEvents;
|
||||
use sp_rpc::{list::ListOrValue, number::NumberOrHex};
|
||||
use sp_runtime::{
|
||||
@@ -45,7 +42,6 @@ pub use sc_rpc_api::chain::*;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
|
||||
/// Blockchain backend API
|
||||
#[async_trait]
|
||||
trait ChainBackend<Client, Block: BlockT>: Send + Sync + 'static
|
||||
where
|
||||
Block: BlockT + 'static,
|
||||
@@ -64,10 +60,10 @@ where
|
||||
}
|
||||
|
||||
/// Get header of a relay chain block.
|
||||
async fn header(&self, hash: Option<Block::Hash>) -> Result<Option<Block::Header>, Error>;
|
||||
fn header(&self, hash: Option<Block::Hash>) -> Result<Option<Block::Header>, Error>;
|
||||
|
||||
/// Get header and body of a relay chain block.
|
||||
async fn block(&self, hash: Option<Block::Hash>) -> Result<Option<SignedBlock<Block>>, Error>;
|
||||
fn block(&self, hash: Option<Block::Hash>) -> Result<Option<SignedBlock<Block>>, Error>;
|
||||
|
||||
/// Get hash of the n-th block in the canon chain.
|
||||
///
|
||||
@@ -126,7 +122,6 @@ pub struct Chain<Block: BlockT, Client> {
|
||||
backend: Box<dyn ChainBackend<Client, Block>>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<Block, Client> ChainApiServer<NumberFor<Block>, Block::Hash, Block::Header, SignedBlock<Block>>
|
||||
for Chain<Block, Client>
|
||||
where
|
||||
@@ -134,12 +129,12 @@ where
|
||||
Block::Header: Unpin,
|
||||
Client: HeaderBackend<Block> + BlockchainEvents<Block> + 'static,
|
||||
{
|
||||
async fn header(&self, hash: Option<Block::Hash>) -> RpcResult<Option<Block::Header>> {
|
||||
self.backend.header(hash).await.map_err(Into::into)
|
||||
fn header(&self, hash: Option<Block::Hash>) -> RpcResult<Option<Block::Header>> {
|
||||
self.backend.header(hash).map_err(Into::into)
|
||||
}
|
||||
|
||||
async fn block(&self, hash: Option<Block::Hash>) -> RpcResult<Option<SignedBlock<Block>>> {
|
||||
self.backend.block(hash).await.map_err(Into::into)
|
||||
fn block(&self, hash: Option<Block::Hash>) -> RpcResult<Option<SignedBlock<Block>>> {
|
||||
self.backend.block(hash).map_err(Into::into)
|
||||
}
|
||||
|
||||
fn block_hash(
|
||||
|
||||
Reference in New Issue
Block a user