pub struct Checkpoint {
pub sequence: u64,
pub state_hash: [u8; 32],
pub genesis_validators_root: Option<[u8; 32]>,
pub validators: HashMap<[u8; 48], ValidatorState>,
pub timestamp: u64,
}Expand description
A checkpoint of the enclave state
Fields§
§sequence: u64Sequence number at this checkpoint
state_hash: [u8; 32]State hash at this checkpoint
genesis_validators_root: Option<[u8; 32]>Genesis validators root (if set)
validators: HashMap<[u8; 48], ValidatorState>All validator states
timestamp: u64Unix timestamp when checkpoint was created
Implementations§
Source§impl Checkpoint
impl Checkpoint
Sourcepub fn new(
integrity: &StateIntegrity,
validators: HashMap<[u8; 48], ValidatorState>,
) -> Self
pub fn new( integrity: &StateIntegrity, validators: HashMap<[u8; 48], ValidatorState>, ) -> Self
Create a new checkpoint from current state
Sourcepub fn save(&self, path: impl AsRef<Path>) -> Result<(), CheckpointError>
pub fn save(&self, path: impl AsRef<Path>) -> Result<(), CheckpointError>
Save checkpoint to a file (simple, non-atomic)
Sourcepub fn save_atomic(
&self,
path: impl AsRef<Path>,
backup_count: u32,
) -> Result<(), CheckpointError>
pub fn save_atomic( &self, path: impl AsRef<Path>, backup_count: u32, ) -> Result<(), CheckpointError>
Save checkpoint atomically with backup rotation
This method:
- Writes to a temporary file
- Rotates existing checkpoint to backup
- Atomically renames temp to target
- Syncs the parent directory for durability
Sourcepub fn load(path: impl AsRef<Path>) -> Result<Self, CheckpointError>
pub fn load(path: impl AsRef<Path>) -> Result<Self, CheckpointError>
Load checkpoint from a file
Sourcepub fn load_with_recovery(
path: impl AsRef<Path>,
backup_count: u32,
) -> Result<Self, CheckpointError>
pub fn load_with_recovery( path: impl AsRef<Path>, backup_count: u32, ) -> Result<Self, CheckpointError>
Load checkpoint with fallback to backups
Tries to load from the primary checkpoint, then falls back to backups
Sourcepub fn restore_integrity(&self) -> StateIntegrity
pub fn restore_integrity(&self) -> StateIntegrity
Restore state integrity from this checkpoint
Trait Implementations§
Source§impl Clone for Checkpoint
impl Clone for Checkpoint
Source§fn clone(&self) -> Checkpoint
fn clone(&self) -> Checkpoint
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Checkpoint
impl Debug for Checkpoint
Source§impl<'de> Deserialize<'de> for Checkpoint
impl<'de> Deserialize<'de> for Checkpoint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Checkpoint
impl RefUnwindSafe for Checkpoint
impl Send for Checkpoint
impl Sync for Checkpoint
impl Unpin for Checkpoint
impl UnwindSafe for Checkpoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more