Storage map iter (#148)

* Add example file

* Fmt

* Add KeyIter.

* Add iter method to store proc-macro.

* Fetch all values at once.

* Update docs.

* Run rustfmt.

Co-authored-by: Andrew Jones <ascjones@gmail.com>
This commit is contained in:
David Craven
2020-08-05 10:08:12 +02:00
committed by GitHub
parent 663934ca37
commit 271775bf99
5 changed files with 201 additions and 31 deletions
+16 -3
View File
@@ -122,7 +122,7 @@ impl<T: Runtime> Rpc<T> {
/// Fetch a storage key
pub async fn storage(
&self,
key: StorageKey,
key: &StorageKey,
hash: Option<T::Hash>,
) -> Result<Option<StorageData>, Error> {
let params = Params::Array(vec![to_json_value(key)?, to_json_value(hash)?]);
@@ -132,8 +132,8 @@ impl<T: Runtime> Rpc<T> {
}
/// Returns the keys with prefix with pagination support.
/// Up to `count` keys will be returned.
/// If `start_key` is passed, return next keys in storage in lexicographic order.
/// Up to `count` keys will be returned.
/// If `start_key` is passed, return next keys in storage in lexicographic order.
pub async fn storage_keys_paged(
&self,
prefix: Option<StorageKey>,
@@ -170,6 +170,19 @@ impl<T: Runtime> Rpc<T> {
.map_err(Into::into)
}
/// Query historical storage entries
pub async fn query_storage_at(
&self,
keys: &[StorageKey],
at: Option<T::Hash>,
) -> Result<Vec<StorageChangeSet<<T as System>::Hash>>, Error> {
let params = Params::Array(vec![to_json_value(keys)?, to_json_value(at)?]);
self.client
.request("state_queryStorage", params)
.await
.map_err(Into::into)
}
/// Fetch the genesis hash
pub async fn genesis_hash(&self) -> Result<T::Hash, Error> {
let block_zero = Some(ListOrValue::Value(NumberOrHex::Number(0)));