rpc: Use substrate provided subscription ID

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2022-12-12 12:14:26 +00:00
parent 8142851926
commit 7561b86d40
2 changed files with 5 additions and 11 deletions
+1 -4
View File
@@ -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| {
+4 -7
View File
@@ -872,14 +872,11 @@ impl<T: Config> Rpc<T> {
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<T: Config> Rpc<T> {
let bytes = self
.fetch_chainhead_call(
subscription_id,
subscription_id.clone(),
event.finalized_block_hash,
"Metadata_metadata".into(),
&vec![],
@@ -910,7 +907,7 @@ impl<T: Config> Rpc<T> {
.client
.request(
"chainHead_unstable_unfollow",
rpc_params![subscription_id_rpc],
rpc_params![subscription_id],
)
.await?;