Skip to content

Commit

Permalink
feat: add subscribe_safe_block & subscribe_finalized_block to `Ca…
Browse files Browse the repository at this point in the history
…nonicalInMemoryState` (#10317)
  • Loading branch information
unitezen authored Aug 20, 2024
1 parent cd05a96 commit 6898c30
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/chain-state/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ impl CanonicalInMemoryState {
self.inner.canon_state_notification_sender.subscribe()
}

/// Subscribe to new safe block events.
pub fn subscribe_safe_block(&self) -> watch::Receiver<Option<SealedHeader>> {
self.inner.chain_info_tracker.subscribe_to_safe_block()
}

/// Subscribe to new finalized block events.
pub fn subscribe_finalized_block(&self) -> watch::Receiver<Option<SealedHeader>> {
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();
Expand Down

0 comments on commit 6898c30

Please sign in to comment.