Add RPC function state_getProof, resolves #1110 (#5649)

* Add RPC function state_getProof, resolves #1110

* Apply suggestions from code review

* Update client/rpc/src/state/state_full.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update Cargo.lock

* Make block hash optional

* Wrap StorageProof as Bytes

* Add struct ReadProof

* Fix typo

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Yuanchao Sun
2020-04-21 03:09:55 +08:00
committed by GitHub
parent 0ce9657db2
commit 52d0173ec3
5 changed files with 82 additions and 7 deletions
@@ -17,6 +17,7 @@
//! Substrate state API.
pub mod error;
pub mod helpers;
use jsonrpc_core::Result as RpcResult;
use jsonrpc_core::futures::Future;
@@ -28,6 +29,7 @@ use sp_version::RuntimeVersion;
use self::error::FutureResult;
pub use self::gen_client::Client as StateClient;
pub use self::helpers::ReadProof;
/// Substrate state API
#[rpc]
@@ -100,6 +102,10 @@ pub trait StateApi<Hash> {
at: Option<Hash>,
) -> FutureResult<Vec<StorageChangeSet<Hash>>>;
/// Returns proof of storage entries at a specific block's state.
#[rpc(name = "state_getReadProof")]
fn read_proof(&self, keys: Vec<StorageKey>, hash: Option<Hash>) -> FutureResult<ReadProof<Hash>>;
/// New runtime version subscription
#[pubsub(
subscription = "state_runtimeVersion",