mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Use more appropriate names for forkchoice subscriptions (#10401)
This commit is contained in:
@ -123,12 +123,12 @@ impl ChainInfoTracker {
|
||||
}
|
||||
|
||||
/// Subscribe to the finalized block.
|
||||
pub fn subscribe_to_finalized_block(&self) -> watch::Receiver<Option<SealedHeader>> {
|
||||
pub fn subscribe_finalized_block(&self) -> watch::Receiver<Option<SealedHeader>> {
|
||||
self.inner.finalized_block.subscribe()
|
||||
}
|
||||
|
||||
/// Subscribe to the safe block.
|
||||
pub fn subscribe_to_safe_block(&self) -> watch::Receiver<Option<SealedHeader>> {
|
||||
pub fn subscribe_safe_block(&self) -> watch::Receiver<Option<SealedHeader>> {
|
||||
self.inner.safe_block.subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,12 +465,12 @@ impl CanonicalInMemoryState {
|
||||
|
||||
/// 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()
|
||||
self.inner.chain_info_tracker.subscribe_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()
|
||||
self.inner.chain_info_tracker.subscribe_finalized_block()
|
||||
}
|
||||
|
||||
/// Attempts to send a new [`CanonStateNotification`] to all active Receiver handles.
|
||||
|
||||
@ -146,14 +146,19 @@ pub struct ForkChoiceNotifications(pub watch::Receiver<Option<SealedHeader>>);
|
||||
/// and get notified when a new fork choice is available.
|
||||
pub trait ForkChoiceSubscriptions: Send + Sync {
|
||||
/// Get notified when a new safe block of the chain is selected.
|
||||
fn subscribe_to_safe_block(&self) -> ForkChoiceNotifications;
|
||||
fn subscribe_safe_block(&self) -> ForkChoiceNotifications;
|
||||
|
||||
/// Get notified when a new finalized block of the chain is selected.
|
||||
fn subscribe_to_finalized_block(&self) -> ForkChoiceNotifications;
|
||||
fn subscribe_finalized_block(&self) -> ForkChoiceNotifications;
|
||||
|
||||
/// Convenience method to get a stream of the new safe blocks of the chain.
|
||||
fn fork_choice_stream(&self) -> ForkChoiceStream {
|
||||
ForkChoiceStream { st: WatchStream::new(self.subscribe_to_safe_block().0) }
|
||||
fn safe_block_stream(&self) -> ForkChoiceStream {
|
||||
ForkChoiceStream { st: WatchStream::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) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1435,12 +1435,12 @@ impl<DB> ForkChoiceSubscriptions for BlockchainProvider2<DB>
|
||||
where
|
||||
DB: Send + Sync,
|
||||
{
|
||||
fn subscribe_to_safe_block(&self) -> ForkChoiceNotifications {
|
||||
fn subscribe_safe_block(&self) -> ForkChoiceNotifications {
|
||||
let receiver = self.canonical_in_memory_state.subscribe_safe_block();
|
||||
ForkChoiceNotifications(receiver)
|
||||
}
|
||||
|
||||
fn subscribe_to_finalized_block(&self) -> ForkChoiceNotifications {
|
||||
fn subscribe_finalized_block(&self) -> ForkChoiceNotifications {
|
||||
let receiver = self.canonical_in_memory_state.subscribe_finalized_block();
|
||||
ForkChoiceNotifications(receiver)
|
||||
}
|
||||
|
||||
@ -944,13 +944,13 @@ impl<DB> ForkChoiceSubscriptions for BlockchainProvider<DB>
|
||||
where
|
||||
DB: Send + Sync,
|
||||
{
|
||||
fn subscribe_to_safe_block(&self) -> ForkChoiceNotifications {
|
||||
let receiver = self.chain_info.subscribe_to_safe_block();
|
||||
fn subscribe_safe_block(&self) -> ForkChoiceNotifications {
|
||||
let receiver = self.chain_info.subscribe_safe_block();
|
||||
ForkChoiceNotifications(receiver)
|
||||
}
|
||||
|
||||
fn subscribe_to_finalized_block(&self) -> ForkChoiceNotifications {
|
||||
let receiver = self.chain_info.subscribe_to_finalized_block();
|
||||
fn subscribe_finalized_block(&self) -> ForkChoiceNotifications {
|
||||
let receiver = self.chain_info.subscribe_finalized_block();
|
||||
ForkChoiceNotifications(receiver)
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,12 +557,12 @@ impl CanonStateSubscriptions for NoopProvider {
|
||||
}
|
||||
|
||||
impl ForkChoiceSubscriptions for NoopProvider {
|
||||
fn subscribe_to_safe_block(&self) -> ForkChoiceNotifications {
|
||||
fn subscribe_safe_block(&self) -> ForkChoiceNotifications {
|
||||
let (_, rx) = watch::channel(None);
|
||||
ForkChoiceNotifications(rx)
|
||||
}
|
||||
|
||||
fn subscribe_to_finalized_block(&self) -> ForkChoiceNotifications {
|
||||
fn subscribe_finalized_block(&self) -> ForkChoiceNotifications {
|
||||
let (_, rx) = watch::channel(None);
|
||||
ForkChoiceNotifications(rx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user