merkledag 2.0.0
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.fromBytesnow verifies a node. It hashes the received body and rejects bytes that do not hash to the embedded CID (or to the optionalexpectedCid). It also rejects truncated input, trailing bytes, and payloads or child lists that are not in canonical form. Failures throwInvalidNodeException.- The hashed content is now the length-prefixed payload followed by the length-prefixed, sorted child CIDs, the same body that
toByteswrites 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
maxTraversalNodesnodes, and stop aftermaxMissingNodesunavailable 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.addbroadcasts after releasing the lock. - New
MerkleCRDT.merge(CID)returns whether the roots changed. Passsubscribe: falseto feed remote heads in yourself.MerkleCRDT.close()cancels the broadcaster subscription.onRemoteUpdateProcessednow fires only when a broadcast changed the roots. MerkleClock.mergereturns whether the roots changed.AbstractMerkleDAG.commonMergeLogicis replaced bymergeHead, which takes the lock itself.getNodetreats a node that theDAGSyncerreturns under a different CID as missing.- New:
MerkleNode.computeCidandMerkleNode.hasValidCid.
1.0.1 #
- First release on pub.dev.
- Content identifiers now come from the
dcidpackage on pub.dev, replacing a localdart_cidpath dependency.