mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-28 00:28:20 -05:00
feat: emit chain notifications (#9732)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
//! Types for tracking the canonical chain state in memory.
|
||||
|
||||
use crate::{CanonStateNotificationSender, CanonStateNotifications, ChainInfoTracker};
|
||||
use crate::{
|
||||
CanonStateNotification, CanonStateNotificationSender, CanonStateNotifications, ChainInfoTracker,
|
||||
};
|
||||
use parking_lot::RwLock;
|
||||
use reth_chainspec::ChainInfo;
|
||||
use reth_execution_types::ExecutionOutcome;
|
||||
@@ -251,6 +253,11 @@ impl CanonicalInMemoryState {
|
||||
pub fn subscribe_canon_state(&self) -> CanonStateNotifications {
|
||||
self.inner.canon_state_notification_sender.subscribe()
|
||||
}
|
||||
|
||||
/// 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();
|
||||
}
|
||||
}
|
||||
|
||||
/// State after applying the given block.
|
||||
|
||||
@@ -1380,7 +1380,9 @@ where
|
||||
// TODO
|
||||
// update inmemory state
|
||||
// update trackers
|
||||
// emit notification
|
||||
|
||||
// sends an event to all active listeners about the new canonical chain
|
||||
self.canonical_in_memory_state.notify_canon_state(update.to_chain_notification());
|
||||
|
||||
if let Some(attr) = attrs {
|
||||
let updated = self.process_payload_attributes(attr, &update.tip().header, state);
|
||||
|
||||
Reference in New Issue
Block a user