earthstar-project / earthstar

Storage for private, distributed, offline-first applications.
https://earthstar-project.org
GNU Lesser General Public License v3.0
637 stars 20 forks source link

Multiformat support, es.5, and attachments #262

Closed sgwilym closed 2 years ago

sgwilym commented 2 years ago

This PR adds support for replicas to hold documents of many formats; a new document format es.5 which can have binary data of any size associated with it; and support for setting, retrieving and syncing this associated data, hereafter referred to as attachments.

Whereas es.4 documents could hold a maximum of 4mb, there is no limit for attachment sizes.

FormatEs5

This is a successor to es.4 with a few key differences:

These documents can be synced sparsely, that is they can be shared around with or without their attachments. It's up to peers to decide if they want a docs attachments or not.

Additionally, IFormatValidator is now IFormat, and has taken on a few new responsibilities: it has methods for generating new docs in addition to simply validating them, and new methods for getting information about a document's attachments.

Replica

Replica drivers

Replica drivers are now composed of two parts: a doc driver and an attachment driver. These have their own interfaces, IReplicaDocDriver and IReplicaAttachmentDriver.

Syncing

Syncing now transfers attachments between peers as well as docs.

Other