mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
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:
@@ -41,6 +41,14 @@ pub enum Error {
|
||||
/// Details of the error message.
|
||||
details: String,
|
||||
},
|
||||
/// Provided count exceeds maximum value.
|
||||
#[display(fmt = "count exceeds maximum value. value: {}, max: {}", value, max)]
|
||||
InvalidCount {
|
||||
/// Provided value
|
||||
value: u32,
|
||||
/// Maximum allowed value
|
||||
max: u32,
|
||||
},
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {
|
||||
@@ -63,6 +71,11 @@ impl From<Error> for rpc::Error {
|
||||
message: format!("{}", e),
|
||||
data: None,
|
||||
},
|
||||
Error::InvalidCount { .. } => rpc::Error {
|
||||
code: rpc::ErrorCode::ServerError(BASE_ERROR + 2),
|
||||
message: format!("{}", e),
|
||||
data: None,
|
||||
},
|
||||
e => errors::internal(e),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>>;
|
||||
|
||||
Reference in New Issue
Block a user