pub struct Wal {
pub header: WalHeader,
pub records: Vec<WalRecord>,
}Expand description
Sealed WAL — the durable read-side counterpart to WalWriter.
Produced by Wal::from_writer or Wal::deserialize; consumed
by Wal::verify_chain / replay_into.
Fields§
§header: WalHeaderHeader pinned at writer construction.
records: Vec<WalRecord>Records in append order.
Implementations§
Source§impl Wal
impl Wal
Sourcepub fn from_writer(w: WalWriter) -> Self
pub fn from_writer(w: WalWriter) -> Self
Sourcepub fn serialize(&self) -> Result<Vec<u8>, WalError>
pub fn serialize(&self) -> Result<Vec<u8>, WalError>
Encode the entire WAL (header + records) as canonical postcard bytes.
Sourcepub fn verify_chain(&self, world_id: [u8; 32]) -> Result<(), WalError>
pub fn verify_chain(&self, world_id: [u8; 32]) -> Result<(), WalError>
Verify every record’s chain hash against the keyed BLAKE3 over
(prev_chain_hash || canonical body). When the header pins a
verifying_key (Tier 2 — Ed25519), each record’s signature
is also checked against the same body bytes. Returns Ok if
every check passes.
Sourcepub fn verify_chain_anchored(
&self,
world_id: [u8; 32],
anchor: &TrustAnchor,
) -> Result<(), WalError>
pub fn verify_chain_anchored( &self, world_id: [u8; 32], anchor: &TrustAnchor, ) -> Result<(), WalError>
Verify the chain AND authenticate it against a caller-supplied
TrustAnchor. Use this when the WAL bytes are untrusted (a
tampered log or a peer’s snapshot): beyond [verify_chain]’s
integrity checks it rejects a tier downgrade below anchor .min_tier, a verifying-key substitution (header key != the
anchored key), a manifest_digest mismatch, and a tail truncation
(tip != the anchored expected_chain_tip). world_id is supplied
by the caller out-of-band — NOT read from the (untrusted) header.