new state api state_getKeys to expose storage keys (#1380)

This commit is contained in:
Xiliang Chen
2019-01-12 00:51:19 +13:00
committed by Gav Wood
parent bf51b8a5ad
commit 0e569e6bf2
7 changed files with 56 additions and 0 deletions
+6
View File
@@ -265,6 +265,12 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
&self.backend
}
/// Return storage entry keys in state in a block of given hash with given prefix.
pub fn storage_keys(&self, id: &BlockId<Block>, key_prefix: &StorageKey) -> error::Result<Vec<StorageKey>> {
let keys = self.state_at(id)?.keys(&key_prefix.0).into_iter().map(StorageKey).collect();
Ok(keys)
}
/// Return single storage entry of contract under given address in state in a block of given hash.
pub fn storage(&self, id: &BlockId<Block>, key: &StorageKey) -> error::Result<Option<StorageData>> {
Ok(self.state_at(id)?
@@ -279,6 +279,11 @@ where
Vec::new()
}
fn keys(&self, _prefix: &Vec<u8>) -> Vec<Vec<u8>> {
// whole state is not available on light node
Vec::new()
}
fn try_into_trie_backend(self) -> Option<TrieBackend<Self::TrieBackendStorage, H>> {
None
}