Everything is a signed log
The core data structure of this whole ecosystem is embarrassingly simple: an
append-only list of blocks, signed by one author. That is a Hypercore.
Why append-only?
- Sync is trivial. "I have 41 entries, you have 38, here are 3 more."
Compare lengths, ship the tail. No diffing, no merge conflicts within a log.
- Verification is built in. Each block is covered by the author's
signature, so replicas can relay each other's copies without being trusted.
- History is honest. You can add, you cannot silently rewrite.
From logs to app state
A log is not an app. The move that makes it one is the fold: every peer
replays every log it follows through a pure reducer into a local view.
for each op in each followed log (any order):
if valid(op): view = apply(view, op)
p2pbuilders' ops are post, comment, vote, edit, tombstone,follow, block, profile… The feed you see is nothing but a fold of
every author log you replicate, indexed into a local database
(Hyperbee).
Two rules make folds sane:
- Ops reference, never contain. A comment points at its parent by id; a
vote points at its target. The fold stitches the graph together.
- The fold must converge. Whatever order ops arrive in, peers that have
the same set of ops must compute the same view. Last-write-wins with a
deterministic tiebreaker covers most records (see
Data patterns).
Delete is a lie (sort of)
You cannot unappend. "Delete" in log-world is a tombstone op that tells
conforming indexers to hide the target. The signed history remains in every
replica. Design for it: say "hidden", not "erased", and never put secrets in a
log.