pub struct DualCommitStore {
pub slot0: Option<CommittedGenerationBytes>,
pub slot1: Option<CommittedGenerationBytes>,
}Expand description
DualCommitStore
Dual-slot protected commit protocol for encoded ledger generations.
Writers stage a complete generation record into the inactive slot. Readers recover by selecting the highest-generation valid slot. A torn or partial write cannot become authoritative unless its marker and checksum validate.
The checksum is for torn-write and accidental-corruption detection only. It is not a cryptographic hash and does not provide adversarial tamper resistance.
Fields§
§slot0: Option<CommittedGenerationBytes>First physical commit slot.
slot1: Option<CommittedGenerationBytes>Second physical commit slot.
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.
Return the highest-generation valid committed record.
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 store models the post-write physical state. If a real
substrate traps before the inactive slot is fully written, the prior
valid slot remains authoritative under authoritative.
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 preferred API for logical ledger commits: the physical slot generation is taken from the logical ledger generation and checked against the recovered physical predecessor.
Sourcepub fn write_corrupt_inactive_slot(&mut self, generation: u64, payload: Vec<u8>)
pub fn write_corrupt_inactive_slot(&mut self, generation: u64, payload: Vec<u8>)
Simulate a torn write into the inactive slot.
This helper is intentionally part of the model because recovery behavior is an ABI requirement, not an implementation detail.
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 moreSource§impl Debug for DualCommitStore
impl Debug for DualCommitStore
Source§impl Default for DualCommitStore
impl Default for DualCommitStore
Source§fn default() -> DualCommitStore
fn default() -> DualCommitStore
Source§impl<'de> Deserialize<'de> for DualCommitStore
impl<'de> Deserialize<'de> for DualCommitStore
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>,
Source§impl DualProtectedCommitStore for DualCommitStore
impl DualProtectedCommitStore for DualCommitStore
Source§type Slot = CommittedGenerationBytes
type Slot = CommittedGenerationBytes
Source§fn is_uninitialized(&self) -> bool
fn is_uninitialized(&self) -> bool
Source§fn inactive_slot_index(&self) -> CommitSlotIndex
fn inactive_slot_index(&self) -> CommitSlotIndex
Source§impl PartialEq for DualCommitStore
impl PartialEq for DualCommitStore
Source§fn eq(&self, other: &DualCommitStore) -> bool
fn eq(&self, other: &DualCommitStore) -> bool
self and other values to be equal, and is used by ==.