pub struct ProllyTree {
pub root: ProllyNode,
pub event_count: usize,
}Expand description
Content-addressed Prolly Tree over a set of events.
Fields§
§root: ProllyNode§event_count: usizeImplementations§
Source§impl ProllyTree
impl ProllyTree
Sourcepub fn build(events: &[Event]) -> Self
pub fn build(events: &[Event]) -> Self
Build a Prolly Tree from a set of events.
Events are sorted by (item_id, wall_ts_us, event_hash), then split
into content-defined chunks using a Gear rolling hash. A balanced
Merkle tree is constructed over the leaf chunks.
The root hash is deterministic for any permutation of the same event set.
Sourcepub fn diff(&self, other: &Self) -> Vec<String>
pub fn diff(&self, other: &Self) -> Vec<String>
Compute the diff between self (local) and other (remote).
Returns event hashes that are in other but not in self.
Runs in O(k log N) where k is the number of differing chunks.
Sourcepub fn event_hashes(&self) -> Vec<String>
pub fn event_hashes(&self) -> Vec<String>
All event hashes stored in this tree.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize to bytes for wire transfer.
§Panics
Panics if serde_json fails to serialize ProllyTree, which should
never happen for well-formed trees.
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, Error>
pub fn from_bytes(data: &[u8]) -> Result<Self, Error>
Deserialize from bytes.
§Errors
Returns a serde_json::Error if the bytes are not valid JSON or do
not match the ProllyTree schema.
Trait Implementations§
Source§impl Clone for ProllyTree
impl Clone for ProllyTree
Source§fn clone(&self) -> ProllyTree
fn clone(&self) -> ProllyTree
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more