pub fn sync<T: SyncTransport>(
local_events: &[Event],
transport: &mut T,
) -> Result<(Vec<Event>, SyncReport), T::Error>Expand description
Synchronise local events with a remote replica.
§Protocol
- Build a Prolly Tree from
local_events. - Exchange root hashes with the remote.
- If hashes match: replicas are identical — return early.
- Diff the trees to identify event hashes missing from each side.
- Send local events that the remote is missing.
- Receive remote events that we are missing.
- Return a
SyncReportsummarising the exchange.
After sync, the caller is responsible for persisting the received events to the local event log and rebuilding the projection.
§Errors
Returns T::Error if any transport operation fails.