rpc: Fetch metadata and runtime using chainHead subscription

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2022-12-07 16:40:46 +00:00
parent 1645a1d3a3
commit ad6a1f2e68
4 changed files with 113 additions and 19 deletions
+3 -2
View File
@@ -31,7 +31,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let genesis = api.rpc().chainhead_genesis_hash().await?;
println!("Genesis: {:?}", genesis);
let mut follow_sub = api.blocks().subscribe_chainhead_finalized(true).await?;
let mut follow_sub = api.blocks().subscribe_chainhead_finalized(false).await?;
println!("Following subscription...");
// Handle all subscriptions from the `chainHead_follow`.
while let Some(block) = follow_sub.next().await {
let block = block?;
@@ -55,7 +56,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let call = block
.call("AccountNonceApi_account_nonce".into(), Some(&call_params))
.await?;
println!("[hash={:?}] call={:?}", block.hash(), call);
// println!("[hash={:?}] call={:?}", block.hash(), call);
}
// Subscribe to the `chainHead_follow` method.