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, fake::Dummy, PartialEq)]
6pub enum PointInTime {
7 /// State of `Account` or `Slot` at the pending block being mined.
8 ///
9 /// If state did not change, then it is the same as the `Mined` state.
10 #[strum(to_string = "pending")]
11 Pending,
12
13 /// State of `Account` or `Slot` at the last mined block.
14 #[default]
15 #[strum(to_string = "mined")]
16 Mined,
17
18 /// State of `Account` or `Slot` at some specific mined block in the past.
19 #[strum(to_string = "mined-past")]
20 MinedPast(BlockNumber),
21}
22
23// -----------------------------------------------------------------------------
24// Conversions: Self -> Other
25// -----------------------------------------------------------------------------
26impl From<PointInTime> for MetricLabelValue {
27 fn from(value: PointInTime) -> Self {
28 Self::Some(value.to_string())
29 }
30}