From abc2bd88b51a7483cd6ffdeee02a747b5b80c743 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Mon, 9 Jan 2023 18:33:19 +0000 Subject: [PATCH] blocks: Unpin block Signed-off-by: Alexandru Vasile --- subxt/src/blocks/block_types.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/subxt/src/blocks/block_types.rs b/subxt/src/blocks/block_types.rs index ecd9e8d085..a6cbce1e05 100644 --- a/subxt/src/blocks/block_types.rs +++ b/subxt/src/blocks/block_types.rs @@ -193,6 +193,22 @@ where self.fetch_call(function, call_parameters).await } + /// Unpin this block. + /// + /// # Note + /// + /// Call this method when you are no longer interested in making queries + /// against this block. + /// + /// Failing to call this method will eventually terminate the subscription. + pub async fn unpin(self) -> Result<(), Error> { + self.client + .rpc() + .chainhead_unpin(self.subscription_id, self.hash) + .await?; + Ok(()) + } + /// Wrapper to fetch the block's body from the `chainHead_body` subscription. async fn fetch_body( &self,