mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 21:41:02 +00:00
Remove support for chainHead_storage for light client
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -13,11 +13,9 @@
|
|||||||
//! This feature is experimental and things might break without notice.
|
//! This feature is experimental and things might break without notice.
|
||||||
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use sp_keyring::AccountKeyring;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use subxt::{
|
use subxt::{
|
||||||
rpc::{types::FollowEvent, LightClient},
|
rpc::{types::FollowEvent, LightClient},
|
||||||
utils::AccountId32,
|
|
||||||
OnlineClient, PolkadotConfig,
|
OnlineClient, PolkadotConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,21 +80,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
} else {
|
} else {
|
||||||
println!(" chainHead_header: Header not in memory for {hash}");
|
println!(" chainHead_header: Header not in memory for {hash}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a storage query.
|
|
||||||
let account_id: AccountId32 = AccountKeyring::Alice.to_account_id().into();
|
|
||||||
let addr = polkadot::storage().system().account(account_id);
|
|
||||||
let addr_bytes = api.storage().address_bytes(&addr).unwrap();
|
|
||||||
|
|
||||||
let mut sub = api
|
|
||||||
.rpc()
|
|
||||||
.chainhead_unstable_storage(sub_id.clone(), hash, &addr_bytes, None)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
if let Some(event) = sub.next().await {
|
|
||||||
let event = event?;
|
|
||||||
println!(" chainHead_storage event: {event:?}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -509,16 +509,7 @@ pub enum FollowEvent<Hash> {
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct ChainHeadResult<T> {
|
pub struct ChainHeadResult<T> {
|
||||||
/// Result of the method.
|
/// Result of the method.
|
||||||
#[cfg(not(feature = "unstable-light-client"))]
|
|
||||||
pub result: T,
|
pub result: T,
|
||||||
/// Result of the method.
|
|
||||||
///
|
|
||||||
/// # Note
|
|
||||||
///
|
|
||||||
/// `chainHead_body` returns a vector of values, while
|
|
||||||
/// `chainHead_storage` returns just one plain element.
|
|
||||||
#[cfg(feature = "unstable-light-client")]
|
|
||||||
pub value: T,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The event generated by the body / call / storage methods.
|
/// The event generated by the body / call / storage methods.
|
||||||
|
|||||||
@@ -501,9 +501,8 @@ async fn chainhead_unstable_body() {
|
|||||||
let extrinsics: Vec<Vec<u8>> = body.block.extrinsics.into_iter().map(|ext| ext.0).collect();
|
let extrinsics: Vec<Vec<u8>> = body.block.extrinsics.into_iter().map(|ext| ext.0).collect();
|
||||||
let expected = format!("0x{}", hex::encode(extrinsics.encode()));
|
let expected = format!("0x{}", hex::encode(extrinsics.encode()));
|
||||||
|
|
||||||
#[cfg(feature = "unstable-light-client")]
|
|
||||||
assert_matches!(event,
|
assert_matches!(event,
|
||||||
ChainHeadEvent::Done(done) if done.value == expected
|
ChainHeadEvent::Done(done) if done.result == expected
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,8 +556,7 @@ async fn chainhead_unstable_storage() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let event = sub.next().await.unwrap().unwrap();
|
let event = sub.next().await.unwrap().unwrap();
|
||||||
|
|
||||||
#[cfg(feature = "unstable-light-client")]
|
assert_matches!(event, ChainHeadEvent::<Option<String>>::Done(done) if done.result.is_some());
|
||||||
assert_matches!(event, ChainHeadEvent::<Option<String>>::Done(done) if done.value.is_some());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|||||||
Reference in New Issue
Block a user