mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 01:11:10 +00:00
Add ability to iterate over N map storage keys (#537)
* Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update artifacts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Change CLI default to bytes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Storage query example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update storage_query example with different alternatives Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Make calls with StorageKey instead of the prefix Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Examples: Add double map storage iteration Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Use tracing_subscriber for logs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
+2
-4
@@ -28,7 +28,6 @@ use std::{
|
||||
|
||||
use crate::{
|
||||
error::BasicError,
|
||||
storage::StorageKeyPrefix,
|
||||
Config,
|
||||
Metadata,
|
||||
PhantomDataSendSync,
|
||||
@@ -277,13 +276,12 @@ impl<T: Config> Rpc<T> {
|
||||
/// If `start_key` is passed, return next keys in storage in lexicographic order.
|
||||
pub async fn storage_keys_paged(
|
||||
&self,
|
||||
prefix: Option<StorageKeyPrefix>,
|
||||
key: Option<StorageKey>,
|
||||
count: u32,
|
||||
start_key: Option<StorageKey>,
|
||||
hash: Option<T::Hash>,
|
||||
) -> Result<Vec<StorageKey>, BasicError> {
|
||||
let prefix = prefix.map(|p| p.to_storage_key());
|
||||
let params = rpc_params![prefix, count, start_key, hash];
|
||||
let params = rpc_params![key, count, start_key, hash];
|
||||
let data = self.client.request("state_getKeysPaged", params).await?;
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
@@ -235,10 +235,10 @@ impl<'a, T: Config> StorageClient<'a, T> {
|
||||
start_key: Option<StorageKey>,
|
||||
hash: Option<T::Hash>,
|
||||
) -> Result<Vec<StorageKey>, BasicError> {
|
||||
let prefix = StorageKeyPrefix::new::<F>();
|
||||
let key = StorageKeyPrefix::new::<F>().to_storage_key();
|
||||
let keys = self
|
||||
.rpc
|
||||
.storage_keys_paged(Some(prefix), count, start_key, hash)
|
||||
.storage_keys_paged(Some(key), count, start_key, hash)
|
||||
.await?;
|
||||
Ok(keys)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user