From b8bc86a33f52ac0e0a04125674f7e7d8f4434055 Mon Sep 17 00:00:00 2001 From: unitezen Date: Thu, 15 Aug 2024 17:40:00 +0700 Subject: [PATCH] Add subscribe_safe_block & subscribe_finalized_block to CanonicalInMemoryState --- crates/chain-state/src/in_memory.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/chain-state/src/in_memory.rs b/crates/chain-state/src/in_memory.rs index 069726277b38..96d98bf8368f 100644 --- a/crates/chain-state/src/in_memory.rs +++ b/crates/chain-state/src/in_memory.rs @@ -465,6 +465,16 @@ impl CanonicalInMemoryState { self.inner.canon_state_notification_sender.subscribe() } + /// Subscribe to new safe block events. + pub fn subscribe_safe_block(&self) -> watch::Receiver> { + self.inner.chain_info_tracker.subscribe_to_safe_block() + } + + /// Subscribe to new finalized block events. + pub fn subscribe_finalized_block(&self) -> watch::Receiver> { + self.inner.chain_info_tracker.subscribe_to_finalized_block() + } + /// Attempts to send a new [`CanonStateNotification`] to all active Receiver handles. pub fn notify_canon_state(&self, event: CanonStateNotification) { self.inner.canon_state_notification_sender.send(event).ok();