Skip to main content

solana_entry/
recorder_message.rs

1//! Message types emitted by the PoH recording pipeline.
2//!
3//! This module defines `RecorderMessage`, a wrapper type that allows regular entries, block markers,
4//! and slot lifecycle notifications to flow through the same PoH recording channel.
5use crate::{block_component::VersionedBlockMarker, entry::Entry};
6
7/// A message emitted by the PoH recorder for an entry, block marker, or control notification.
8///
9/// The PoH recorder uses this type to stream entries, block markers, and control notifications
10/// through a unified channel to downstream consumers, e.g., broadcast stage.
11#[derive(Clone, Debug)]
12#[allow(clippy::large_enum_variant)]
13pub enum RecorderMessage {
14    /// The working bank for a new slot has been installed; tell broadcast to wake up.
15    SlotStart,
16    /// A regular entry containing transactions and/or ticks
17    Entry(Entry),
18    /// A block metadata marker (header or footer)
19    Marker(VersionedBlockMarker),
20}
21
22#[cfg(feature = "dev-context-only-utils")]
23impl RecorderMessage {
24    pub fn unwrap_entry(self) -> Entry {
25        match self {
26            Self::SlotStart => panic!("Attempting to unwrap slot start as entry"),
27            Self::Entry(e) => e,
28            Self::Marker(marker) => panic!("Attempting to unwrap marker as entry {marker:?}"),
29        }
30    }
31}
32
33/// Converts an Entry into a RecorderMessage.
34impl From<Entry> for RecorderMessage {
35    fn from(entry: Entry) -> Self {
36        RecorderMessage::Entry(entry)
37    }
38}
39
40/// Converts a VersionedBlockMarker into a RecorderMessage.
41impl From<VersionedBlockMarker> for RecorderMessage {
42    fn from(marker: VersionedBlockMarker) -> Self {
43        RecorderMessage::Marker(marker)
44    }
45}