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)

Verify the content binding even on the first write. Existing refs remain byte-identical and storage errors are failures, never a missing value. Legacy inspect-rendered definitions cannot be verified and fail closed.

pub fn connect(
  peer: sync_types.PeerId,
) -> Result(Nil, sync_types.SyncError)

Open a connection to a peer. Stays open for subsequent fetch_refs batches — the selective-pull primitive’s session handle.

pub fn fetch_refs(
  peer: sync_types.PeerId,
  codebase: codebase.Codebase,
  hexes: List(String),
) -> Result(codebase.Codebase, sync_types.SyncError)

Fetch exactly the given refs from an already-connected peer: request, unsolicited-chunk validation, conflict-checked accept. Returns the codebase with the chunks applied. This is the selective transfer primitive: the caller computes the ref set (e.g. a package manifest closure) and the wire moves nothing else.

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