mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-07 04:57:22 +00:00
archive: Implement archive_unstable_storage (#1846)
This PR implements the `archive_unstable_storage` method that offers support for: - fetching values - fetching hashes - iterating over keys and values - iterating over keys and hashes - fetching merkle values from the trie-db A common component dedicated to RPC-V2 storage queries is created to bridge the gap between `chainHead/storage` and `archive/storage`. Query pagination is supported by `paginationStartKey`, similar to the old APIs. Similarly to the `chainHead/storage`, the `archive/storage` method accepts a maximum number of queried items. The design builds upon: https://github.com/paritytech/json-rpc-interface-spec/pull/94. Closes https://github.com/paritytech/polkadot-sdk/issues/1512. cc @paritytech/subxt-team --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
@@ -24,6 +24,9 @@
|
||||
#![deny(unused_crate_dependencies)]
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sp_core::hexdisplay::{AsBytesRef, HexDisplay};
|
||||
|
||||
mod common;
|
||||
|
||||
pub mod archive;
|
||||
pub mod chain_head;
|
||||
@@ -39,7 +42,7 @@ pub type SubscriptionTaskExecutor = std::sync::Arc<dyn sp_core::traits::SpawnNam
|
||||
pub enum MethodResult {
|
||||
/// Method generated a result.
|
||||
Ok(MethodResultOk),
|
||||
/// Method ecountered an error.
|
||||
/// Method encountered an error.
|
||||
Err(MethodResultErr),
|
||||
}
|
||||
|
||||
@@ -75,6 +78,11 @@ pub struct MethodResultErr {
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
/// Util function to encode a value as a hex string
|
||||
pub fn hex_string<Data: AsBytesRef>(data: &Data) -> String {
|
||||
format!("0x{:?}", HexDisplay::from(data))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user