mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
new state api state_getKeys to expose storage keys (#1380)
This commit is contained in:
@@ -51,6 +51,10 @@ build_rpc_trait! {
|
||||
#[rpc(name = "state_call", alias = ["state_callAt", ])]
|
||||
fn call(&self, String, Bytes, Trailing<Hash>) -> Result<Bytes>;
|
||||
|
||||
/// Returns the keys with prefix, leave empty to get all the keys
|
||||
#[rpc(name = "state_getKeys")]
|
||||
fn storage_keys(&self, StorageKey, Trailing<Hash>) -> Result<Vec<StorageKey>>;
|
||||
|
||||
/// Returns a storage entry at a specific block's state.
|
||||
#[rpc(name = "state_getStorage", alias = ["state_getStorageAt", ])]
|
||||
fn storage(&self, StorageKey, Trailing<Hash>) -> Result<Option<StorageData>>;
|
||||
@@ -148,6 +152,12 @@ impl<B, E, Block, RA> StateApi<Block::Hash> for State<B, E, Block, RA> where
|
||||
Ok(Bytes(return_data))
|
||||
}
|
||||
|
||||
fn storage_keys(&self, key_prefix: StorageKey, block: Trailing<Block::Hash>) -> Result<Vec<StorageKey>> {
|
||||
let block = self.unwrap_or_best(block)?;
|
||||
trace!(target: "rpc", "Querying storage keys at {:?}", block);
|
||||
Ok(self.client.storage_keys(&BlockId::Hash(block), &key_prefix)?)
|
||||
}
|
||||
|
||||
fn storage(&self, key: StorageKey, block: Trailing<Block::Hash>) -> Result<Option<StorageData>> {
|
||||
let block = self.unwrap_or_best(block)?;
|
||||
trace!(target: "rpc", "Querying storage at {:?} for key {}", block, HexDisplay::from(&key.0));
|
||||
|
||||
Reference in New Issue
Block a user