From d3e959bbd025631046d91819a924509e599afad6 Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Tue, 24 Sep 2024 20:06:13 +0100 Subject: [PATCH] fix(chain-state): fork choice stream should return only when changed (#11178) --- crates/chain-state/src/notifications.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/chain-state/src/notifications.rs b/crates/chain-state/src/notifications.rs index c1ab009cf..fc717314b 100644 --- a/crates/chain-state/src/notifications.rs +++ b/crates/chain-state/src/notifications.rs @@ -153,14 +153,12 @@ pub trait ForkChoiceSubscriptions: Send + Sync { /// Convenience method to get a stream of the new safe blocks of the chain. fn safe_block_stream(&self) -> ForkChoiceStream { - ForkChoiceStream:: { st: WatchStream::new(self.subscribe_safe_block().0) } + ForkChoiceStream::new(self.subscribe_safe_block().0) } /// Convenience method to get a stream of the new finalized blocks of the chain. fn finalized_block_stream(&self) -> ForkChoiceStream { - ForkChoiceStream:: { - st: WatchStream::new(self.subscribe_finalized_block().0), - } + ForkChoiceStream::new(self.subscribe_finalized_block().0) } } @@ -175,7 +173,7 @@ pub struct ForkChoiceStream { impl ForkChoiceStream { /// Creates a new `ForkChoiceStream` pub fn new(rx: watch::Receiver>) -> Self { - Self { st: WatchStream::new(rx) } + Self { st: WatchStream::from_changes(rx) } } }