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