Skip to main content

start_epoch

Function start_epoch 

Source
async fn start_epoch(
    io: &dyn WalObjectIo,
    object_seq: u64,
    tip: Option<ChainLink>,
) -> Result<ChainLink>
Expand description

Writes the empty object that starts the epoch of this instance at object_seq, linked to the recovered tip, and returns it as the tip later objects extend. The epoch is one above the sequence the create claims, so no two instances share one however their opens interleave, and it is above the epoch of every object recovery listed.

An object an earlier instance left at that sequence after recovery listed the prefix has a lower epoch and never ends a chain, so the start object moves to the next sequence and epoch. An object of an equal or later epoch belongs to another writer of the prefix, and the conflict fails the open, as does a create whose outcome is unknown: the next open counts the object in either case. So does a create that finds the same bytes present: another open that recovered the same objects writes an identical start object, so this open cannot claim the epoch even if the object is its own.