stratus/eth/primitives/
point_in_time.rs

1use crate::eth::primitives::BlockNumber;
2use crate::infra::metrics::MetricLabelValue;
3
4/// EVM storage point-in-time indicator.
5#[derive(Debug, strum::Display, Clone, Copy, Default, strum::EnumIs, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
6#[cfg_attr(test, derive(fake::Dummy))]
7pub enum PointInTime {
8    /// State of `Account` or `Slot` at the pending block being mined.
9    ///
10    /// If state did not change, then it is the same as the `Mined` state.
11    #[strum(to_string = "pending")]
12    Pending,
13
14    /// State of `Account` or `Slot` at the last mined block.
15    #[default]
16    #[strum(to_string = "mined")]
17    Mined,
18
19    /// State of `Account` or `Slot` at some specific mined block in the past.
20    #[strum(to_string = "mined-past")]
21    MinedPast(BlockNumber),
22}
23
24// -----------------------------------------------------------------------------
25// Conversions: Self -> Other
26// -----------------------------------------------------------------------------
27impl From<PointInTime> for MetricLabelValue {
28    fn from(value: PointInTime) -> Self {
29        Self::Some(value.to_string())
30    }
31}