pub struct DualCommitStore { /* private fields */ }Expand description
DualCommitStore
Redundant commit store for encoded ledger generations.
This is an advanced low-level API for framework or stable-IO owners. Most applications should recover, validate, and commit through the allocation ledger flow rather than manipulating encoded physical commit slots directly.
Writers stage a complete generation record into the inactive slot. Readers recover by selecting the highest-generation slot after every present slot passes marker and checksum validation. Any present invalid slot fails closed; recovery never rolls durable allocation history back to an older generation.
In the default runtime both slots are serialized together inside one
ic-stable-structures::Cell; they are not independently atomic physical
writes. ICP message execution supplies atomic stable-memory commit and
rollback. The checksum is for accidental-corruption detection only. It is
not a cryptographic hash and does not provide adversarial tamper resistance.
Implementations§
Source§impl DualCommitStore
impl DualCommitStore
Sourcepub const fn is_uninitialized(&self) -> bool
pub const fn is_uninitialized(&self) -> bool
Return true when no commit slot has ever been written.
Sourcepub const fn slot0(&self) -> Option<&CommittedGenerationBytes>
pub const fn slot0(&self) -> Option<&CommittedGenerationBytes>
Borrow the first commit slot.
Slot records are untrusted recovered state until recovery selects an authoritative generation.
Sourcepub const fn slot1(&self) -> Option<&CommittedGenerationBytes>
pub const fn slot1(&self) -> Option<&CommittedGenerationBytes>
Borrow the second commit slot.
Slot records are untrusted recovered state until recovery selects an authoritative generation.
Return the authoritative committed record after validating present slots.
Sourcepub fn diagnostic(&self) -> CommitStoreDiagnostic
pub fn diagnostic(&self) -> CommitStoreDiagnostic
Build a read-only recovery diagnostic for the protected commit slots.
Sourcepub fn commit_payload(
&mut self,
payload: Vec<u8>,
) -> Result<&CommittedGenerationBytes, CommitRecoveryError>
pub fn commit_payload( &mut self, payload: Vec<u8>, ) -> Result<&CommittedGenerationBytes, CommitRecoveryError>
Commit a new payload to the inactive slot.
The returned record is the new authoritative in-memory slot. The owner remains responsible for persisting the enclosing store.
Sourcepub fn commit_payload_at_generation(
&mut self,
generation: u64,
payload: Vec<u8>,
) -> Result<&CommittedGenerationBytes, CommitRecoveryError>
pub fn commit_payload_at_generation( &mut self, generation: u64, payload: Vec<u8>, ) -> Result<&CommittedGenerationBytes, CommitRecoveryError>
Commit payload as an explicitly numbered physical generation.
This is the low-level physical-slot primitive used by
crate::LedgerCommitStore. Normal ledger commits should use
crate::LedgerCommitStore::commit or crate::AllocationBootstrap so
payloads are decoded, current-format checked, and integrity-validated
before they can become authoritative.
The commit-slot generation is checked against the recovered
predecessor. This method does not inspect payload.
Trait Implementations§
Source§impl Clone for DualCommitStore
impl Clone for DualCommitStore
Source§fn clone(&self) -> DualCommitStore
fn clone(&self) -> DualCommitStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more