add state_getKeysPaged (#4718)

* add storage_getNextKey

* RPC storage_getKeysPages

* respect count

* use iterator

* improve

* add tests

* improve

* add doc comments

* Make prefix optional

* update error

* improve
This commit is contained in:
Xiliang Chen
2020-02-04 22:44:40 +13:00
committed by GitHub
parent 900295b020
commit febb6e29b2
6 changed files with 199 additions and 3 deletions
+14 -1
View File
@@ -39,10 +39,23 @@ pub trait StateApi<Hash> {
#[rpc(name = "state_call", alias("state_callAt"))]
fn call(&self, name: String, bytes: Bytes, hash: Option<Hash>) -> FutureResult<Bytes>;
/// Returns the keys with prefix, leave empty to get all the keys
/// DEPRECATED: Please use `state_getKeysPaged` with proper paging support.
/// Returns the keys with prefix, leave empty to get all the keys.
#[rpc(name = "state_getKeys")]
fn storage_keys(&self, prefix: StorageKey, hash: Option<Hash>) -> FutureResult<Vec<StorageKey>>;
/// 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.
#[rpc(name = "state_getKeysPaged", alias("state_getKeysPagedAt"))]
fn storage_keys_paged(
&self,
prefix: Option<StorageKey>,
count: u32,
start_key: Option<StorageKey>,
hash: Option<Hash>,
) -> FutureResult<Vec<StorageKey>>;
/// Returns a storage entry at a specific block's state.
#[rpc(name = "state_getStorage", alias("state_getStorageAt"))]
fn storage(&self, key: StorageKey, hash: Option<Hash>) -> FutureResult<Option<StorageData>>;