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
@@ -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),
}
}