From 7561b86d40b78f8779a27cb7527bf2910509c1ee Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Mon, 12 Dec 2022 12:14:26 +0000 Subject: [PATCH] rpc: Use substrate provided subscription ID Signed-off-by: Alexandru Vasile --- subxt/src/blocks/blocks_client.rs | 5 +---- subxt/src/rpc/rpc.rs | 11 ++++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/subxt/src/blocks/blocks_client.rs b/subxt/src/blocks/blocks_client.rs index b760967cc3..91848762e3 100644 --- a/subxt/src/blocks/blocks_client.rs +++ b/subxt/src/blocks/blocks_client.rs @@ -172,14 +172,11 @@ where .subscribe_chainhead_follow(runtime_updates) .await?; - let _subscription_id = match sub.subscription_id() { + let subscription_id = match sub.subscription_id() { Some(id) => id.clone(), None => return Err(Error::Other("Subscription without ID".into())), }; - // TODO: Jsonrpsee needs update. - let subscription_id = "A".to_string(); - // Flatten the finalized events and map them into a `FollowBlock`. Ok(sub .flat_map(move |event| { diff --git a/subxt/src/rpc/rpc.rs b/subxt/src/rpc/rpc.rs index f673352b66..e6396d82f9 100644 --- a/subxt/src/rpc/rpc.rs +++ b/subxt/src/rpc/rpc.rs @@ -872,14 +872,11 @@ impl Rpc { let (bytes, event) = { let mut sub = self.subscribe_chainhead_follow(true).await?; - let subscription_id_rpc = match sub.subscription_id() { + let subscription_id = match sub.subscription_id() { Some(id) => id.clone(), None => return Err(Error::Other("Subscription without ID".into())), }; - println!("Recv from jsonrpsee: {:?}", subscription_id_rpc); - - // TODO: Jsonrpsee needs update. - let subscription_id = "A".to_string(); + println!("RPC Subscription ID: {:?}", subscription_id); let event = match sub.next().await { Some(event) => event, @@ -899,7 +896,7 @@ impl Rpc { let bytes = self .fetch_chainhead_call( - subscription_id, + subscription_id.clone(), event.finalized_block_hash, "Metadata_metadata".into(), &vec![], @@ -910,7 +907,7 @@ impl Rpc { .client .request( "chainHead_unstable_unfollow", - rpc_params![subscription_id_rpc], + rpc_params![subscription_id], ) .await?;