mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 00:37:57 +00:00
RPC: Mark storage methods as blocking (#11459)
* client/api: Make `storage_keys` blocking Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client/api: Ensure `state_*` RPC methods are blocking Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client/rpc: Ensure `childstate_*` RPC methods are blocking Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client/rpc: `ChainApi` make RPC methods sync Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Remove unused async-traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client/rpc-api: Make chain RPC methods blocking Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update client/rpc/src/state/state_full.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Add `blocking` to `state_getKeysPaged` RPC call Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix build and warning Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Remove `async_trait` tidyup Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -26,24 +26,24 @@ pub mod error;
|
||||
#[rpc(client, server)]
|
||||
pub trait ChainApi<Number, Hash, Header, SignedBlock> {
|
||||
/// Get header.
|
||||
#[method(name = "chain_getHeader")]
|
||||
async fn header(&self, hash: Option<Hash>) -> RpcResult<Option<Header>>;
|
||||
#[method(name = "chain_getHeader", blocking)]
|
||||
fn header(&self, hash: Option<Hash>) -> RpcResult<Option<Header>>;
|
||||
|
||||
/// Get header and body of a relay chain block.
|
||||
#[method(name = "chain_getBlock")]
|
||||
async fn block(&self, hash: Option<Hash>) -> RpcResult<Option<SignedBlock>>;
|
||||
#[method(name = "chain_getBlock", blocking)]
|
||||
fn block(&self, hash: Option<Hash>) -> RpcResult<Option<SignedBlock>>;
|
||||
|
||||
/// Get hash of the n-th block in the canon chain.
|
||||
///
|
||||
/// By default returns latest block hash.
|
||||
#[method(name = "chain_getBlockHash", aliases = ["chain_getHead"])]
|
||||
#[method(name = "chain_getBlockHash", aliases = ["chain_getHead"], blocking)]
|
||||
fn block_hash(
|
||||
&self,
|
||||
hash: Option<ListOrValue<NumberOrHex>>,
|
||||
) -> RpcResult<ListOrValue<Option<Hash>>>;
|
||||
|
||||
/// Get hash of the last finalized block in the canon chain.
|
||||
#[method(name = "chain_getFinalizedHead", aliases = ["chain_getFinalisedHead"])]
|
||||
#[method(name = "chain_getFinalizedHead", aliases = ["chain_getFinalisedHead"], blocking)]
|
||||
fn finalized_head(&self) -> RpcResult<Hash>;
|
||||
|
||||
/// All head subscription.
|
||||
|
||||
@@ -28,9 +28,9 @@ use sp_core::storage::{PrefixedStorageKey, StorageData, StorageKey};
|
||||
#[rpc(client, server)]
|
||||
pub trait ChildStateApi<Hash> {
|
||||
/// Returns the keys with prefix from a child storage, leave empty to get all the keys
|
||||
#[method(name = "childstate_getKeys")]
|
||||
#[method(name = "childstate_getKeys", blocking)]
|
||||
#[deprecated(since = "2.0.0", note = "Please use `getKeysPaged` with proper paging support")]
|
||||
async fn storage_keys(
|
||||
fn storage_keys(
|
||||
&self,
|
||||
child_storage_key: PrefixedStorageKey,
|
||||
prefix: StorageKey,
|
||||
@@ -40,8 +40,8 @@ pub trait ChildStateApi<Hash> {
|
||||
/// Returns the keys with prefix from a child storage with pagination support.
|
||||
/// Up to `count` keys will be returned.
|
||||
/// If `start_key` is passed, return next keys in storage in lexicographic order.
|
||||
#[method(name = "childstate_getKeysPaged", aliases = ["childstate_getKeysPagedAt"])]
|
||||
async fn storage_keys_paged(
|
||||
#[method(name = "childstate_getKeysPaged", aliases = ["childstate_getKeysPagedAt"], blocking)]
|
||||
fn storage_keys_paged(
|
||||
&self,
|
||||
child_storage_key: PrefixedStorageKey,
|
||||
prefix: Option<StorageKey>,
|
||||
@@ -51,8 +51,8 @@ pub trait ChildStateApi<Hash> {
|
||||
) -> RpcResult<Vec<StorageKey>>;
|
||||
|
||||
/// Returns a child storage entry at a specific block's state.
|
||||
#[method(name = "childstate_getStorage")]
|
||||
async fn storage(
|
||||
#[method(name = "childstate_getStorage", blocking)]
|
||||
fn storage(
|
||||
&self,
|
||||
child_storage_key: PrefixedStorageKey,
|
||||
key: StorageKey,
|
||||
@@ -60,8 +60,8 @@ pub trait ChildStateApi<Hash> {
|
||||
) -> RpcResult<Option<StorageData>>;
|
||||
|
||||
/// Returns child storage entries for multiple keys at a specific block's state.
|
||||
#[method(name = "childstate_getStorageEntries")]
|
||||
async fn storage_entries(
|
||||
#[method(name = "childstate_getStorageEntries", blocking)]
|
||||
fn storage_entries(
|
||||
&self,
|
||||
child_storage_key: PrefixedStorageKey,
|
||||
keys: Vec<StorageKey>,
|
||||
@@ -69,8 +69,8 @@ pub trait ChildStateApi<Hash> {
|
||||
) -> RpcResult<Vec<Option<StorageData>>>;
|
||||
|
||||
/// Returns the hash of a child storage entry at a block's state.
|
||||
#[method(name = "childstate_getStorageHash")]
|
||||
async fn storage_hash(
|
||||
#[method(name = "childstate_getStorageHash", blocking)]
|
||||
fn storage_hash(
|
||||
&self,
|
||||
child_storage_key: PrefixedStorageKey,
|
||||
key: StorageKey,
|
||||
@@ -78,8 +78,8 @@ pub trait ChildStateApi<Hash> {
|
||||
) -> RpcResult<Option<Hash>>;
|
||||
|
||||
/// Returns the size of a child storage entry at a block's state.
|
||||
#[method(name = "childstate_getStorageSize")]
|
||||
async fn storage_size(
|
||||
#[method(name = "childstate_getStorageSize", blocking)]
|
||||
fn storage_size(
|
||||
&self,
|
||||
child_storage_key: PrefixedStorageKey,
|
||||
key: StorageKey,
|
||||
@@ -87,8 +87,8 @@ pub trait ChildStateApi<Hash> {
|
||||
) -> RpcResult<Option<u64>>;
|
||||
|
||||
/// Returns proof of storage for child key entries at a specific block's state.
|
||||
#[method(name = "state_getChildReadProof")]
|
||||
async fn read_child_proof(
|
||||
#[method(name = "state_getChildReadProof", blocking)]
|
||||
fn read_child_proof(
|
||||
&self,
|
||||
child_storage_key: PrefixedStorageKey,
|
||||
keys: Vec<StorageKey>,
|
||||
|
||||
@@ -34,21 +34,17 @@ pub use self::helpers::ReadProof;
|
||||
#[rpc(client, server)]
|
||||
pub trait StateApi<Hash> {
|
||||
/// Call a contract at a block's state.
|
||||
#[method(name = "state_call", aliases = ["state_callAt"])]
|
||||
async fn call(&self, name: String, bytes: Bytes, hash: Option<Hash>) -> RpcResult<Bytes>;
|
||||
#[method(name = "state_call", aliases = ["state_callAt"], blocking)]
|
||||
fn call(&self, name: String, bytes: Bytes, hash: Option<Hash>) -> RpcResult<Bytes>;
|
||||
|
||||
/// Returns the keys with prefix, leave empty to get all the keys.
|
||||
#[method(name = "state_getKeys")]
|
||||
#[method(name = "state_getKeys", blocking)]
|
||||
#[deprecated(since = "2.0.0", note = "Please use `getKeysPaged` with proper paging support")]
|
||||
async fn storage_keys(
|
||||
&self,
|
||||
prefix: StorageKey,
|
||||
hash: Option<Hash>,
|
||||
) -> RpcResult<Vec<StorageKey>>;
|
||||
fn storage_keys(&self, prefix: StorageKey, hash: Option<Hash>) -> RpcResult<Vec<StorageKey>>;
|
||||
|
||||
/// Returns the keys with prefix, leave empty to get all the keys
|
||||
#[method(name = "state_getPairs")]
|
||||
async fn storage_pairs(
|
||||
#[method(name = "state_getPairs", blocking)]
|
||||
fn storage_pairs(
|
||||
&self,
|
||||
prefix: StorageKey,
|
||||
hash: Option<Hash>,
|
||||
@@ -57,8 +53,8 @@ pub trait StateApi<Hash> {
|
||||
/// 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.
|
||||
#[method(name = "state_getKeysPaged", aliases = ["state_getKeysPagedAt"])]
|
||||
async fn storage_keys_paged(
|
||||
#[method(name = "state_getKeysPaged", aliases = ["state_getKeysPagedAt"], blocking)]
|
||||
fn storage_keys_paged(
|
||||
&self,
|
||||
prefix: Option<StorageKey>,
|
||||
count: u32,
|
||||
@@ -67,32 +63,32 @@ pub trait StateApi<Hash> {
|
||||
) -> RpcResult<Vec<StorageKey>>;
|
||||
|
||||
/// Returns a storage entry at a specific block's state.
|
||||
#[method(name = "state_getStorage", aliases = ["state_getStorageAt"])]
|
||||
async fn storage(&self, key: StorageKey, hash: Option<Hash>) -> RpcResult<Option<StorageData>>;
|
||||
#[method(name = "state_getStorage", aliases = ["state_getStorageAt"], blocking)]
|
||||
fn storage(&self, key: StorageKey, hash: Option<Hash>) -> RpcResult<Option<StorageData>>;
|
||||
|
||||
/// Returns the hash of a storage entry at a block's state.
|
||||
#[method(name = "state_getStorageHash", aliases = ["state_getStorageHashAt"])]
|
||||
async fn storage_hash(&self, key: StorageKey, hash: Option<Hash>) -> RpcResult<Option<Hash>>;
|
||||
#[method(name = "state_getStorageHash", aliases = ["state_getStorageHashAt"], blocking)]
|
||||
fn storage_hash(&self, key: StorageKey, hash: Option<Hash>) -> RpcResult<Option<Hash>>;
|
||||
|
||||
/// Returns the size of a storage entry at a block's state.
|
||||
#[method(name = "state_getStorageSize", aliases = ["state_getStorageSizeAt"])]
|
||||
async fn storage_size(&self, key: StorageKey, hash: Option<Hash>) -> RpcResult<Option<u64>>;
|
||||
#[method(name = "state_getStorageSize", aliases = ["state_getStorageSizeAt"], blocking)]
|
||||
fn storage_size(&self, key: StorageKey, hash: Option<Hash>) -> RpcResult<Option<u64>>;
|
||||
|
||||
/// Returns the runtime metadata as an opaque blob.
|
||||
#[method(name = "state_getMetadata")]
|
||||
async fn metadata(&self, hash: Option<Hash>) -> RpcResult<Bytes>;
|
||||
#[method(name = "state_getMetadata", blocking)]
|
||||
fn metadata(&self, hash: Option<Hash>) -> RpcResult<Bytes>;
|
||||
|
||||
/// Get the runtime version.
|
||||
#[method(name = "state_getRuntimeVersion", aliases = ["chain_getRuntimeVersion"])]
|
||||
async fn runtime_version(&self, hash: Option<Hash>) -> RpcResult<RuntimeVersion>;
|
||||
#[method(name = "state_getRuntimeVersion", aliases = ["chain_getRuntimeVersion"], blocking)]
|
||||
fn runtime_version(&self, hash: Option<Hash>) -> RpcResult<RuntimeVersion>;
|
||||
|
||||
/// Query historical storage entries (by key) starting from a block given as the second
|
||||
/// parameter.
|
||||
///
|
||||
/// NOTE This first returned result contains the initial state of storage for all keys.
|
||||
/// Subsequent values in the vector represent changes to the previous state (diffs).
|
||||
#[method(name = "state_queryStorage")]
|
||||
async fn query_storage(
|
||||
#[method(name = "state_queryStorage", blocking)]
|
||||
fn query_storage(
|
||||
&self,
|
||||
keys: Vec<StorageKey>,
|
||||
block: Hash,
|
||||
@@ -100,20 +96,16 @@ pub trait StateApi<Hash> {
|
||||
) -> RpcResult<Vec<StorageChangeSet<Hash>>>;
|
||||
|
||||
/// Query storage entries (by key) starting at block hash given as the second parameter.
|
||||
#[method(name = "state_queryStorageAt")]
|
||||
async fn query_storage_at(
|
||||
#[method(name = "state_queryStorageAt", blocking)]
|
||||
fn query_storage_at(
|
||||
&self,
|
||||
keys: Vec<StorageKey>,
|
||||
at: Option<Hash>,
|
||||
) -> RpcResult<Vec<StorageChangeSet<Hash>>>;
|
||||
|
||||
/// Returns proof of storage entries at a specific block's state.
|
||||
#[method(name = "state_getReadProof")]
|
||||
async fn read_proof(
|
||||
&self,
|
||||
keys: Vec<StorageKey>,
|
||||
hash: Option<Hash>,
|
||||
) -> RpcResult<ReadProof<Hash>>;
|
||||
#[method(name = "state_getReadProof", blocking)]
|
||||
fn read_proof(&self, keys: Vec<StorageKey>, hash: Option<Hash>) -> RpcResult<ReadProof<Hash>>;
|
||||
|
||||
/// New runtime version subscription
|
||||
#[subscription(
|
||||
@@ -285,8 +277,8 @@ pub trait StateApi<Hash> {
|
||||
///
|
||||
/// If you are having issues with maximum payload size you can use the flag
|
||||
/// `-ltracing=trace` to get some logging during tracing.
|
||||
#[method(name = "state_traceBlock")]
|
||||
async fn trace_block(
|
||||
#[method(name = "state_traceBlock", blocking)]
|
||||
fn trace_block(
|
||||
&self,
|
||||
block: Hash,
|
||||
targets: Option<String>,
|
||||
|
||||
Reference in New Issue
Block a user