mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 02:01:02 +00:00
xxx: Backup
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -98,23 +98,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let mut sub = api
|
let mut sub = api
|
||||||
.rpc()
|
.rpc()
|
||||||
.chainhead_unstable_body(sub_id.clone(), hash)
|
.chainhead_unstable_body(sub_id.clone(), hash)
|
||||||
.await?
|
.await?;
|
||||||
.take(5);
|
|
||||||
|
|
||||||
while let Some(event) = sub.next().await {
|
if let Some(event) = sub.next().await {
|
||||||
let event = event?;
|
let event = event?;
|
||||||
|
|
||||||
println!(" chainHead_body event: {event:?}");
|
println!(" chainHead_body event: {event:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the block's header.
|
// Fetch the block's header.
|
||||||
// let header = api
|
let header = api
|
||||||
// .rpc()
|
.rpc()
|
||||||
// .chainhead_unstable_header(sub_id.clone(), hash)
|
.chainhead_unstable_header(sub_id.clone(), hash)
|
||||||
// .await?;
|
.await?;
|
||||||
// let header = header.expect("RPC must have this header in memory; qed");
|
if let Some(header) = header {
|
||||||
|
println!(" chainHead_header: {header}");
|
||||||
// println!(" chainHead_header: {header}");
|
} else {
|
||||||
|
println!(" chainHead_header: Header not in memory for {hash}");
|
||||||
|
}
|
||||||
|
|
||||||
// Make a storage query.
|
// Make a storage query.
|
||||||
let account_id: AccountId32 = AccountKeyring::Alice.to_account_id().into();
|
let account_id: AccountId32 = AccountKeyring::Alice.to_account_id().into();
|
||||||
@@ -124,12 +124,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let mut sub = api
|
let mut sub = api
|
||||||
.rpc()
|
.rpc()
|
||||||
.chainhead_unstable_storage(sub_id.clone(), hash, &addr_bytes, None)
|
.chainhead_unstable_storage(sub_id.clone(), hash, &addr_bytes, None)
|
||||||
.await?
|
.await?;
|
||||||
.take(5);
|
|
||||||
|
|
||||||
while let Some(event) = sub.next().await {
|
if let Some(event) = sub.next().await {
|
||||||
let event = event?;
|
let event = event?;
|
||||||
|
|
||||||
println!(" chainHead_storage event: {event:?}");
|
println!(" chainHead_storage event: {event:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -507,15 +507,46 @@ pub enum FollowEvent<Hash> {
|
|||||||
/// The result of a chain head method.
|
/// The result of a chain head method.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[cfg(feature = "experimental-light-client")]
|
||||||
|
#[serde(try_from = "LightClientChainHeadResult<T>")]
|
||||||
pub struct ChainHeadResult<T> {
|
pub struct ChainHeadResult<T> {
|
||||||
/// Result of the method.
|
/// Result of the method.
|
||||||
#[cfg(not(feature = "experimental-light-client"))]
|
#[cfg(not(feature = "experimental-light-client"))]
|
||||||
pub result: T,
|
pub result: T,
|
||||||
/// Result of the method.
|
/// Result of the method.
|
||||||
|
///
|
||||||
|
/// # Note
|
||||||
|
///
|
||||||
|
/// `chainHead_body` returns a vector of values, while
|
||||||
|
/// `chainHead_storage` returns just one plain element.
|
||||||
#[cfg(feature = "experimental-light-client")]
|
#[cfg(feature = "experimental-light-client")]
|
||||||
pub value: Vec<T>,
|
pub value: Vec<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The result of a chain head method.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[cfg(feature = "experimental-light-client")]
|
||||||
|
pub struct LightClientChainHeadResult<T> {
|
||||||
|
/// Result of the method.
|
||||||
|
///
|
||||||
|
/// # Note
|
||||||
|
///
|
||||||
|
/// `chainHead_body` returns a vector of values, while
|
||||||
|
/// `chainHead_storage` returns just one plain element.
|
||||||
|
pub value: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> TryFrom<LightClientChainHeadResult<T>> for ChainHeadResult<T> {
|
||||||
|
type Error = &'static str;
|
||||||
|
|
||||||
|
fn try_from(light: LightClientChainHeadResult<T>) -> Result<Self, &'static str> {
|
||||||
|
Ok(Self {
|
||||||
|
value: vec![light.value],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The event generated by the body / call / storage methods.
|
/// The event generated by the body / call / storage methods.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
|||||||
Reference in New Issue
Block a user