fix(chain-state): fork choice stream should return only when changed (#11178)

This commit is contained in:
Alexey Shekhirin
2024-09-24 20:06:13 +01:00
committed by GitHub
parent c434e52632
commit d3e959bbd0

View File

@ -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<SealedHeader> {
ForkChoiceStream::<SealedHeader> { 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<SealedHeader> {
ForkChoiceStream::<SealedHeader> {
st: WatchStream::new(self.subscribe_finalized_block().0),
}
ForkChoiceStream::new(self.subscribe_finalized_block().0)
}
}
@ -175,7 +173,7 @@ pub struct ForkChoiceStream<T> {
impl<T: Clone + Sync + Send + 'static> ForkChoiceStream<T> {
/// Creates a new `ForkChoiceStream`
pub fn new(rx: watch::Receiver<Option<T>>) -> Self {
Self { st: WatchStream::new(rx) }
Self { st: WatchStream::from_changes(rx) }
}
}