PRO

Effect Merkle Anti-Entropy Sync

Reconciling two replicas by shipping the difference, not the dataset. Comparing a million keys row by row (or resending everything) costs bandwidth proportional to the data even when replicas differ by one row. A Merkle tree hashes data into a tree of digests; two nodes compare root hashes and only descend into subtrees whose hashes differ, so bytes moved track the number of changed keys. A collision-resistant hash rolled to the root means equal roots imply equal contents and any single change alters every hash on its path, so divergence cannot hide. The demo finds one changed key among 64 by visiting 13 tree nodes, then repairs to convergence. Pinned to effect 4.0.0-beta.98.

Install
npx shadcn@latest add https://ui.aryank.space/r/effect-merkle-anti-entropy.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
sync
compare 64 keys
readonly Key[]
for k in allKeys: compare(a[k], b[k]) // O(n)

Reconciling two replicas by comparing key-by-key (or resending the dataset) moves bytes proportional to the data, even when they differ by a single row out of 64.

Files

Dependencies