Skip to main content

settle_loss_batch

Function settle_loss_batch 

Source
pub fn settle_loss_batch(state: AuditLosses, batch: AuditLosses) -> AuditLosses
Expand description

Settle the pending losses state against a durable marker that reports batch, at the writer’s commit and at open-time reconciliation alike.

A marker settles only its own generation, and only the count it reports. Losses that AuditHandle::emit added after the writer’s snapshot stay pending, and move to the next generation. The host only ever moves a generation forward, so no marker already in the spool names that one: no later reconciliation settles them a second time, and the next marker names a generation newer than the last, as audit_loss_marker_admission requires. A marker of another generation settles nothing.

A batch larger than the pending count settles it to zero. The host never produces one – a batch is a snapshot of the pending count, which only grows within a generation until settled – so that case is clamped, not conserved. At u64::MAX the generation saturates rather than bumps; that takes 2^64 settlements and is the host’s to rule out.