gleamunison/sync

Values

pub fn accept_chunk(
  peer: sync_types.PeerId,
  codebase: codebase.Codebase,
  ref: identity.DefinitionRef,
  bytes: BitArray,
) -> Result(codebase.Codebase, sync_types.SyncError)

Accept one chunk from a peer under CAS discipline: a ref already held must map to byte-identical content — first write wins, and any later conflicting bytes for the same ref are a HashConflict, never an overwrite. Fresh refs store raw. This is the check that makes “content- addressed” mean something on the wire: once any honest peer’s bytes land, no peer can rewrite that ref’s binding.

Known boundary: storage holds inspect-rendered bytes whose structural hash cannot be recomputed from the bytes alone, so a first write still trusts the sender. Full binding needs canonical serialization (the known debug-serialization debt); until then, consistency pinning is the honest check with teeth.

pub fn validate_chunk_set(
  requested: List(String),
  received: List(#(String, BitArray)),
) -> Result(Nil, sync_types.SyncError)

Every received chunk must answer a ref we actually asked for. A peer sending unsolicited chunks fails the transfer loudly.

✨ Search Document