Module log_sync

Source
Expand description

Efficient bidirectional sync protocol for append-only log data types.

This implementation is generic over the actual data type implementation, as long as it follows the form of a numbered, linked list it will be compatible for sync. p2panda provides an own log implementation in p2panda-core which can be easily combined with this sync protocol.

The protocol checks the current local “log heights”, that is the index of the latest known entry in each log, of the “initiating” peer and sends them in form of a “Have” message to the remote peer. The “accepting” remote peer matches the given log heights with the locally present ones, calculates the delta of missing entries and sends them to the initiating peer as part of “Data” messages. The accepting peer then sends a “Done” message to signal that data transmission is complete. The protocol exchange is then repeated with the roles reversed: the accepting peer sends their “Have” message and the initiating peer responds with the required “Data” messages, followed by a final “Done” message.

To find out which logs to send matching the given “topic query” a TopicLogMap is provided. This interface aids the sync protocol in deciding which logs to transfer for each given topic.

Structs§

LogSyncProtocol
Efficient sync protocol for append-only log data types.

Traits§

TopicLogMap
Maps a TopicQuery to the related logs being sent over the wire during sync.