Extends ChildStateBackend and ChildStateAPI with ReadProofs (#8812)

* Extends ChildStateBackend and ChildStateAPI with ReadProofs

The following changes integrate the existing `read_child_proof`
from the `ProofProvider` into the ChildStateBackend, so that a
read proof can be generated from a full client via an rpc call.

* Cleanup formatting
This commit is contained in:
Frederik Schulz
2021-05-17 11:59:10 +02:00
committed by GitHub
parent fcf83c0278
commit 59f34ab8bc
4 changed files with 64 additions and 0 deletions
+18
View File
@@ -382,6 +382,14 @@ pub trait ChildStateBackend<Block: BlockT, Client>: Send + Sync + 'static
Block: BlockT + 'static,
Client: Send + Sync + 'static,
{
/// Returns proof of storage for a child key entries at a specific block's state.
fn read_child_proof(
&self,
block: Option<Block::Hash>,
storage_key: PrefixedStorageKey,
keys: Vec<StorageKey>,
) -> FutureResult<ReadProof<Block::Hash>>;
/// Returns the keys with prefix from a child storage,
/// leave prefix empty to get all the keys.
fn storage_keys(
@@ -431,6 +439,15 @@ impl<Block, Client> ChildStateApi<Block::Hash> for ChildState<Block, Client>
{
type Metadata = crate::Metadata;
fn read_child_proof(
&self,
child_storage_key: PrefixedStorageKey,
keys: Vec<StorageKey>,
block: Option<Block::Hash>,
) -> FutureResult<ReadProof<Block::Hash>> {
self.backend.read_child_proof(block, child_storage_key, keys)
}
fn storage(
&self,
storage_key: PrefixedStorageKey,
@@ -466,6 +483,7 @@ impl<Block, Client> ChildStateApi<Block::Hash> for ChildState<Block, Client>
) -> FutureResult<Option<u64>> {
self.backend.storage_size(block, storage_key, key)
}
}
fn client_err(err: sp_blockchain::Error) -> Error {