Remove support for chainHead_storage for light client

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-05-25 17:47:52 +03:00
parent f405c897dc
commit 8e46da77ee
3 changed files with 2 additions and 30 deletions
@@ -13,11 +13,9 @@
//! This feature is experimental and things might break without notice.
use futures::StreamExt;
use sp_keyring::AccountKeyring;
use std::sync::Arc;
use subxt::{
rpc::{types::FollowEvent, LightClient},
utils::AccountId32,
OnlineClient, PolkadotConfig,
};
@@ -82,21 +80,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} else {
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:?}");
}
}
}
-9
View File
@@ -509,16 +509,7 @@ pub enum FollowEvent<Hash> {
#[serde(rename_all = "camelCase")]
pub struct ChainHeadResult<T> {
/// Result of the method.
#[cfg(not(feature = "unstable-light-client"))]
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.
+2 -4
View File
@@ -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 expected = format!("0x{}", hex::encode(extrinsics.encode()));
#[cfg(feature = "unstable-light-client")]
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();
let event = sub.next().await.unwrap().unwrap();
#[cfg(feature = "unstable-light-client")]
assert_matches!(event, ChainHeadEvent::<Option<String>>::Done(done) if done.value.is_some());
assert_matches!(event, ChainHeadEvent::<Option<String>>::Done(done) if done.result.is_some());
}
#[tokio::test]