Skip to main content

merkledag 2.0.0 copy "merkledag: ^2.0.0" to clipboard
merkledag: ^2.0.0 copied to clipboard

Merkle-CRDTs in Dart: a content-addressed Merkle-DAG with Merkle clocks, so replicas converge over an unreliable, transport-agnostic network.

2.0.0 #

Breaking: CIDs change, and serialized nodes from 1.x do not load.

  • MerkleNode.fromBytes now verifies a node. It hashes the received body and rejects bytes that do not hash to the embedded CID (or to the optional expectedCid). It also rejects truncated input, trailing bytes, and payloads or child lists that are not in canonical form. Failures throw InvalidNodeException.
  • The hashed content is now the length-prefixed payload followed by the length-prefixed, sorted child CIDs, the same body that toBytes writes after the CID. The old encoding concatenated the payload with child CID strings, so different payload/children splits could share a CID. Every CID changes, so stores written by 1.x must be rebuilt.
  • DAG traversal is bounded. Walks keep a visited set (diamond-shaped DAGs were exponential), visit at most maxTraversalNodes nodes, and stop after maxMissingNodes unavailable nodes. Merging walks the remote and local DAGs together and stops where they meet, so its cost follows how far replicas diverged, not how long history is. When a walk is cut short, the remote head is kept as an extra root, which is safe for state-based payloads.
  • Merges no longer hold the lock while fetching. If the roots change during the walk, the merge plans again against the new roots, so concurrent merges of a chain leave only the newest head. MerkleCRDT.add broadcasts after releasing the lock.
  • New MerkleCRDT.merge(CID) returns whether the roots changed. Pass subscribe: false to feed remote heads in yourself. MerkleCRDT.close() cancels the broadcaster subscription. onRemoteUpdateProcessed now fires only when a broadcast changed the roots.
  • MerkleClock.merge returns whether the roots changed.
  • AbstractMerkleDAG.commonMergeLogic is replaced by mergeHead, which takes the lock itself.
  • getNode treats a node that the DAGSyncer returns under a different CID as missing.
  • New: MerkleNode.computeCid and MerkleNode.hasValidCid.

1.0.1 #

  • First release on pub.dev.
  • Content identifiers now come from the dcid package on pub.dev, replacing a local dart_cid path dependency.
0
likes
150
points
351
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Merkle-CRDTs in Dart: a content-addressed Merkle-DAG with Merkle clocks, so replicas converge over an unreliable, transport-agnostic network.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

collection, crypto, dcid, logging, synchronized

More

Packages that depend on merkledag