Skip to content

Commit

Permalink
Revert "Remove non-RPC storage_entries functions."
Browse files Browse the repository at this point in the history
This reverts commit d840015.
  • Loading branch information
hirschenberger committed Sep 9, 2021
1 parent d840015 commit 5813b43
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client/rpc/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ where
key: StorageKey,
) -> FutureResult<Option<StorageData>>;

/// Returns storage entries for multiple keys at a specific block's state.
fn storage_entries(
&self,
block: Option<Block::Hash>,
keys: Vec<StorageKey>,
) -> FutureResult<Vec<Option<StorageData>>>;

/// Returns the hash of a storage entry at a block's state.
fn storage_hash(
&self,
Expand Down
20 changes: 19 additions & 1 deletion client/rpc/src/state/state_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,24 @@ where
async move { r }.boxed()
}

fn storage_entries(
&self,
block: Option<Block::Hash>,
keys: Vec<StorageKey>,
) -> FutureResult<Vec<Option<StorageData>>> {
let block = match self.block_or_best(block) {
Ok(b) => b,
Err(e) => return err(client_err(e)).boxed(),
};
let client = self.client.clone();
try_join_all(keys.into_iter().map(move |key| {
let res = client.storage(&BlockId::Hash(block), &key).map_err(client_err);

async move { res }
}))
.boxed()
}

fn storage_size(
&self,
block: Option<Block::Hash>,
Expand Down Expand Up @@ -740,7 +758,7 @@ where
.clone()
.child_storage(&BlockId::Hash(block), &child_info, &key)
.map_err(client_err);

async move {
res
}
Expand Down
11 changes: 11 additions & 0 deletions client/rpc/src/state/state_light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,17 @@ where
.boxed()
}

fn storage_entries(
&self,
block: Option<Block::Hash>,
keys: Vec<StorageKey>,
) -> FutureResult<Vec<Option<StorageData>>> {
let keys = keys.iter().map(|k| k.0.clone()).collect::<Vec<_>>();
storage(&*self.remote_blockchain, self.fetcher.clone(), self.block_or_best(block), keys)
.map_ok(|v| v.into_iter().map(|x| x.1).collect::<Vec<_>>())
.boxed()
}

fn storage_hash(
&self,
block: Option<Block::Hash>,
Expand Down

0 comments on commit 5813b43

Please sign in to comment.