v0.3.5-pre.002
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
// file: crates/ksp-interface-lib/src/lib.rs
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
//! Passive wire contracts shared by KSP Program implementations.
|
||||
//! Passive contracts shared across KSP component boundaries.
|
||||
//!
|
||||
//! The foundation reuses the canonical Solana [`Pubkey`] owned by
|
||||
//! `ksp-core-lib` and exposes only bounded, passive Program-facing structures.
|
||||
//! Runtime, transport, persistence and Program behavior remain outside this
|
||||
//! crate.
|
||||
//! The crate reuses canonical Solana primitives owned by `ksp-core-lib` and
|
||||
//! exposes only bounded, passive Program-facing and provider-neutral
|
||||
//! acquisition structures. Runtime, transport, persistence and Program
|
||||
//! behavior remain outside this crate.
|
||||
|
||||
mod error;
|
||||
mod program_account_meta;
|
||||
mod program_instruction;
|
||||
mod slot_lifecycle;
|
||||
|
||||
/// Error code used when an Interface-owned Program instruction admission limit is exceeded.
|
||||
pub use self::error::ERROR_CODE_PROGRAM_INSTRUCTION_LIMIT_EXCEEDED;
|
||||
@@ -26,5 +27,9 @@ pub use self::program_account_meta::ProgramAccountMeta;
|
||||
pub use self::program_instruction::MAX_PROGRAM_INSTRUCTION_DATA_LEN;
|
||||
/// Passive, bounded Program instruction wire contract.
|
||||
pub use self::program_instruction::ProgramInstruction;
|
||||
/// Passive provider-neutral occurrence of one slot lifecycle stage.
|
||||
pub use self::slot_lifecycle::SlotLifecycleEvent;
|
||||
/// Provider-neutral stage in the lifecycle of an observed Solana slot.
|
||||
pub use self::slot_lifecycle::SlotLifecycleStage;
|
||||
/// Canonical Solana account address primitive owned by `ksp-core-lib`.
|
||||
pub use ksp_core_lib::Pubkey;
|
||||
|
||||
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