Expand description
ยงmdcs-merkle
Merkle-Clock DAG implementation for the MDCS (Merkle-Delta CRDT Store).
This crate provides:
- Content-addressed storage for causal history
- Merkle-DAG structure for verifiable, tamper-proof history
- DAGSyncer for gap-repair and synchronization
- Broadcaster for gossip-based head dissemination
ยงArchitecture
The Merkle-Clock serves as a logical clock that:
- Provides verifiable causal ordering via hash-linked nodes
- Enables gap-repair through content-addressed fetching
- Supports open membership without metadata bloat
- Handles concurrent updates via multi-root DAGs
ยงExample
use mdcs_merkle::{MerkleNode, Payload, MemoryDAGStore, DAGStore, NodeBuilder};
// Create a DAG store
let mut store = MemoryDAGStore::new();
// Create the genesis node
let genesis = NodeBuilder::new()
.with_payload(Payload::genesis())
.build();
let genesis_cid = store.put(genesis).unwrap();
// Create a child node referencing the genesis
let child = NodeBuilder::new()
.with_parents(vec![genesis_cid])
.with_payload(Payload::delta(vec![1, 2, 3]))
.build();
let child_cid = store.put(child).unwrap();
// The child is now a head
assert_eq!(store.heads(), vec![child_cid]);Modulesยง
- broadcaster ๐
- Gossip-based broadcasting for head dissemination.
- hash ๐
- Content-addressed hashing for Merkle nodes.
- node ๐
- Merkle node definition and builder.
- store ๐
- DAG storage trait and implementations.
- syncer ๐
- DAG synchronization with gap-repair logic.
Structsยง
- Broadcast
Config - Configuration for the broadcaster.
- Broadcast
Message - A broadcast message containing head announcements.
- Broadcast
Network - Simulates a network of broadcasters for testing.
- Broadcaster
- Gossip-based broadcaster for head dissemination.
- DAGSyncer
- DAG synchronizer for gap-repair and reconciliation.
- Hash
- A 32-byte SHA-256 hash used as a Content Identifier (CID).
- Hasher
- Hasher utility for computing content hashes.
- MemoryDAG
Store - In-memory implementation of DAGStore.
- Merkle
Node - A node in the Merkle-DAG representing a causal event.
- Node
Builder - Builder for creating Merkle nodes.
- Sync
Request - Request to fetch nodes from a peer.
- Sync
Response - Response containing nodes from a peer.
- Sync
Simulator - Simulator for testing sync between multiple replicas.
Enumsยง
- DAGError
- Errors that can occur during DAG operations.
- Payload
- The payload carried by a Merkle node.
- Sync
Error - Errors that can occur during synchronization.
Traitsยง
- DAGStore
- Trait for content-addressed DAG storage.