feat: emit chain notifications (#9732)

This commit is contained in:
Matthias Seitz
2024-07-23 19:36:24 +02:00
committed by GitHub
parent 545bf99f76
commit a6f6346ffe
2 changed files with 11 additions and 2 deletions

View File

@@ -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.

View File

@@ -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);