Expand description
Prolly Tree sync protocol for non-git event replication.
Two replicas exchange Prolly Tree root hashes, identify divergent subtrees in O(log N), and transfer only the missing events.
The protocol is transport-agnostic: any type implementing SyncTransport
can be used (TCP, HTTP, MCP, USB drive via file exchange, etc.).
This is a library module — bones does not own transport. External tools
implement SyncTransport for their chosen medium and call sync /
serve_sync to run the 3-round protocol.
§Protocol rounds
- Root hash exchange — if hashes match, replicas are identical (fast path).
- Event hash exchange — each side sends its full event hash list.
- Event transfer — each side sends events the other is missing.
§Example (in-memory, for testing)
use bones_core::sync::protocol::sync_in_memory;
let result = sync_in_memory(&local_events, &remote_events).unwrap();
// result.local_received — events the local side was missing
// result.remote_received — events the remote side was missing
// result.local_report — sync statisticsStructs§
- InMemory
Error - Error type for in-memory transport (should never happen in tests).
- InMemory
Transport - A pair of in-memory channels for testing sync without real I/O.
- Sync
InMemory Result - Result of an in-memory sync between two replicas.
- Sync
Report - Summary of a completed sync operation.
Traits§
- Sync
Transport - Abstraction over the wire protocol.
Functions§
- serve_
sync - Respond to a sync request as the remote side.
- sync
- Synchronise local events with a remote replica.
- sync_
in_ memory - Run a full sync between two event sets using in-memory transport.