v0.3.5-pre.002
This commit is contained in:
53
crates/ksp-interface-lib/src/slot_lifecycle.rs
Normal file
53
crates/ksp-interface-lib/src/slot_lifecycle.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
// file: crates/ksp-interface-lib/src/slot_lifecycle.rs
|
||||
// version: 1
|
||||
|
||||
/// Provider-neutral stage in the lifecycle of an observed Solana slot.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum SlotLifecycleStage {
|
||||
/// The slot has been processed.
|
||||
Processed,
|
||||
/// The first shred for the slot has been received.
|
||||
FirstShredReceived,
|
||||
/// Slot ingestion has completed.
|
||||
Completed,
|
||||
/// A bank has been created for the slot.
|
||||
CreatedBank,
|
||||
/// The slot has been marked dead.
|
||||
Dead,
|
||||
/// The slot has reached optimistic confirmation.
|
||||
OptimisticallyConfirmed,
|
||||
/// The slot has become rooted.
|
||||
Rooted,
|
||||
}
|
||||
|
||||
/// Passive provider-neutral occurrence of one slot lifecycle stage.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct SlotLifecycleEvent {
|
||||
slot: u64,
|
||||
stage: SlotLifecycleStage,
|
||||
}
|
||||
|
||||
impl SlotLifecycleEvent {
|
||||
/// Creates a lifecycle event for `slot` and `stage`.
|
||||
#[must_use]
|
||||
pub const fn new(slot: u64, stage: SlotLifecycleStage) -> Self {
|
||||
return Self { slot, stage };
|
||||
}
|
||||
|
||||
/// Returns the observed slot exactly as supplied.
|
||||
#[must_use]
|
||||
pub const fn slot(&self) -> u64 {
|
||||
return self.slot;
|
||||
}
|
||||
|
||||
/// Returns the provider-neutral lifecycle stage.
|
||||
#[must_use]
|
||||
pub const fn stage(&self) -> SlotLifecycleStage {
|
||||
return self.stage;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "../unit_tests/slot_lifecycle.rs"]
|
||||
mod tests;
|
||||
Reference in New Issue
Block a user