iroh_sync/lib.rs
1//! Multi-dimensional key-value documents with an efficient synchronization protocol
2//!
3//! The crate operates on [Replicas](Replica). A replica contains an unlimited number of
4//! [Entries][Entry]. Each entry is identified by a key, its author, and the replica's
5//! namespace. Its value is the [32-byte BLAKE3 hash](iroh_base::hash::Hash)
6//! of the entry's content data, the size of this content data, and a timestamp.
7//! The content data itself is not stored or transferred through a replica.
8//!
9//! All entries in a replica are signed with two keypairs:
10//!
11//! * The [`NamespaceSecret`] key, as a token of write capability. The public key is the
12//! [`NamespaceId`], which also serves as the unique identifier for a replica.
13//! * The [Author] key, as a proof of authorship. Any number of authors may be created, and
14//! their semantic meaning is application-specific. The public key of an author is the [AuthorId].
15//!
16//! Replicas can be synchronized between peers by exchanging messages. The synchronization algorithm
17//! is based on a technique called *range-based set reconciliation*, based on [this paper][paper] by
18//! Aljoscha Meyer:
19//!
20//! > Range-based set reconciliation is a simple approach to efficiently compute the union of two
21//! sets over a network, based on recursively partitioning the sets and comparing fingerprints of
22//! the partitions to probabilistically detect whether a partition requires further work.
23//!
24//! The crate exposes a [generic storage interface](store::Store). There is an implementation
25//! of this interface, [store::fs::Store], that can be used either
26//! [in-memory](store::fs::Store::memory) or in
27//! [persistent, file-based](store::fs::Store::persistent) mode.
28//!
29//! Both modes make use of [`redb`], an embedded key-value store. When used
30//! in-memory, the store is backed by a `Vec<u8>`. When used in persistent mode,
31//! the store is backed by a single file on disk.
32//!
33//! [paper]: https://arxiv.org/abs/2212.13567
34#![deny(missing_docs, rustdoc::broken_intra_doc_links)]
35
36pub mod actor;
37mod heads;
38mod keys;
39#[cfg(feature = "metrics")]
40pub mod metrics;
41#[cfg(feature = "net")]
42pub mod net;
43mod ranger;
44pub mod store;
45pub mod sync;
46
47pub use self::heads::*;
48pub use self::keys::*;
49pub use self::sync::*;