Skip to main content

Module sync_transport

Module sync_transport 

Source
Expand description

Sync transport (T3.1) — moves SyncOperations between this node and a peer/relay.

The transport is a dumb pipe: it neither validates nor trusts operations. All trust lives in the inbox’s fail-closed validate_operation — a hostile relay or peer can therefore only ever cause rejections at admission, never the admission of bad data. Convergence is guaranteed by merge_operations (add-wins by operation id), so duplicate / reordered / replayed frames converge to the same validated set.

Two backends:

  • InMemoryRelay — a shared, in-process op store (dedup by operation id). Clone it to get a second handle onto the same relay; two nodes sharing one relay exchange ops. This is the reference transport and the one the convergence / hostile-peer tests run over.
  • HttpRelayTransport (native) — a reqwest::blocking client that POSTs to "{base}/sync/publish" and GETs "{base}/sync/pull?since={cursor}". Its server counterpart is super::sync_relay_server::SyncRelayServer.

Structs§

HttpRelayTransport
An HTTP relay transport (native). POSTs a SyncOpsBody to "{base}/sync/publish" and GETs "{base}/sync/pull?since={cursor}". Mirrors the crate’s reqwest::blocking chat-relay pattern.
InMemoryRelay
A shared in-memory relay — a dumb op store (append-only, dedup by operation id). Cloning yields another handle onto the same underlying store, so two nodes can rendezvous through one relay.
Libp2pSyncTransport
A libp2p SyncTransport (native) — a noise-encrypted request-response pipe to a single peer or relay. It wraps the core-db BlockingSyncClient: each SyncOperation is serialized to a CBOR op frame on publish and decoded back on pull, so the wire carries only opaque signed-op bytes. A dumb pipe like the in-memory and HTTP backends — it never validates or trusts. Undecodable inbound frames are skipped (they could never be admitted anyway; the fail-closed inbox is the trust boundary), so a hostile peer injecting junk cannot break sync for well-formed operations.
SyncOpsBody
The wire body for /sync/publish and the response body for /sync/pull.

Traits§

SyncTransport
Moves operations to/from a peer or relay. A dumb pipe — validation is the inbox’s job.