Make chain && state RPCs async (#3480)

* chain+state RPCs are async now

* wrapped too long lines

* create full/light RPC impls from service

* use ordering

* post-merge fix
This commit is contained in:
Svyatoslav Nikolsky
2019-09-01 03:20:10 +03:00
committed by Gavin Wood
parent 816e132cd7
commit 607ee0a4e4
26 changed files with 1859 additions and 721 deletions
@@ -23,6 +23,9 @@ use jsonrpc_core as rpc;
/// Chain RPC Result type.
pub type Result<T> = std::result::Result<T, Error>;
/// State RPC future Result type.
pub type FutureResult<T> = Box<dyn rpc::futures::Future<Item = T, Error = Error> + Send>;
/// Chain RPC errors.
#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum Error {
+3 -3
View File
@@ -23,7 +23,7 @@ use jsonrpc_core::Result as RpcResult;
use jsonrpc_core::futures::Future;
use jsonrpc_derive::rpc;
use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId};
use self::error::Result;
use self::error::{FutureResult, Result};
pub use self::gen_client::Client as ChainClient;
@@ -35,11 +35,11 @@ pub trait ChainApi<Number, Hash, Header, SignedBlock> {
/// Get header of a relay chain block.
#[rpc(name = "chain_getHeader")]
fn header(&self, hash: Option<Hash>) -> Result<Option<Header>>;
fn header(&self, hash: Option<Hash>) -> FutureResult<Option<Header>>;
/// Get header and body of a relay chain block.
#[rpc(name = "chain_getBlock")]
fn block(&self, hash: Option<Hash>) -> Result<Option<SignedBlock>>;
fn block(&self, hash: Option<Hash>) -> FutureResult<Option<SignedBlock>>;
/// Get hash of the n-th block in the canon chain.
///