rpc: Subscribe to chainHead_follow method

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2022-11-24 15:53:11 +00:00
parent 6c3cd82d4f
commit 85cf4f65dc
+18
View File
@@ -41,6 +41,7 @@
use super::{
rpc_params,
subscription_events::FollowEvent,
RpcClient,
RpcClientT,
Subscription,
@@ -606,6 +607,23 @@ impl<T: Config> Rpc<T> {
Ok(subscription)
}
/// Subscribe to the chain head follow for newly added block hashes.
pub async fn subscribe_chainhead_follow(
&self,
runtime_updates: bool,
) -> Result<Subscription<FollowEvent<T::Hash>>, 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;