Pp2pbuilders
learn › P2P Foundations

7 min read · also at #/learn/handbook-logs

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?

Compare lengths, ship the tail. No diffing, no merge conflicts within a log.

signature, so replicas can relay each other's copies without being trusted.

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:

  1. Ops reference, never contain. A comment points at its parent by id; a

vote points at its target. The fold stitches the graph together.

  1. 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.

« Identity is a keypair How peers find each other »