From 85cf4f65dc82903d6756eac6fb243b92f36d9bd2 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Thu, 24 Nov 2022 15:53:11 +0000 Subject: [PATCH] rpc: Subscribe to `chainHead_follow` method Signed-off-by: Alexandru Vasile --- subxt/src/rpc/rpc.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/subxt/src/rpc/rpc.rs b/subxt/src/rpc/rpc.rs index c12ce885e6..a0e42828a8 100644 --- a/subxt/src/rpc/rpc.rs +++ b/subxt/src/rpc/rpc.rs @@ -41,6 +41,7 @@ use super::{ rpc_params, + subscription_events::FollowEvent, RpcClient, RpcClientT, Subscription, @@ -606,6 +607,23 @@ impl Rpc { Ok(subscription) } + /// Subscribe to the chain head follow for newly added block hashes. + pub async fn subscribe_chainhead_follow( + &self, + runtime_updates: bool, + ) -> Result>, Error> { + let subscription = self + .client + .subscribe( + "chainHead_unstable_follow", + rpc_params![runtime_updates], + "chainHead_unstable_unfollow", + ) + .await?; + + Ok(subscription) + } + /// Subscribe to finalized block headers. /// /// Note: this may not produce _every_ block in the finalized chain;