p2p: incremental sync with digests, inventory and fetch
Peers compare a short digest of revocations, listings and messages on connect and transfer only what differs. Peers without digests are synced the old way. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
+23
-6
@@ -120,11 +120,28 @@ within 30 days.
|
||||
tombstones are stored like any version so old copies cannot resurrect a
|
||||
deleted listing.
|
||||
- **Sync** (`/allmende/1/sync`): on every new connection to a peer a node
|
||||
pulls revocations first, then each subscribed region, paged by a
|
||||
`(created_at, author, id)` keyset cursor. Tombstones are included so
|
||||
deletions propagate. Simultaneous connections to the same peer (e.g. TCP and
|
||||
QUIC) share one running sync. Currently a full pull; a digest-based
|
||||
incremental sync is future work. Gossip lost *while connected* is only
|
||||
catches up incrementally. Simultaneous connections to the same peer (e.g.
|
||||
TCP and QUIC) share one running sync.
|
||||
1. `digest` (no region) returns a digest `{n, root}` of the peer's
|
||||
revocations; if it differs from ours, the revocations are pulled (they
|
||||
are few). Revocations go first so listings of revoked devices are
|
||||
refused.
|
||||
2. For each subscribed region, `digest` returns digests of the region's
|
||||
listings and of its messages. A digest is the record count and a SHA-256
|
||||
over the sorted identities and versions (`author id hash` per listing,
|
||||
`hash` per message; tombstones count, expired records do not). Equal
|
||||
digests: nothing more is sent, which is the usual case.
|
||||
3. When listing digests differ, `inventory` pages through the peer's
|
||||
`(author, id, seq, hash)` list (about 100 bytes per listing). The node
|
||||
keeps the versions it lacks or that beat the one it holds (the conflict
|
||||
rules above) and asks for them with `fetch` (up to 100 `author/id` keys
|
||||
per request). Messages work the same way, keyed by hash. Listings are
|
||||
synced before messages, since owner-bound messages are only accepted for
|
||||
listings we hold.
|
||||
A peer that answers `digest` with a reset (a node from before digests
|
||||
existed) is caught up the original way: kinds `revocations`, `listings` and
|
||||
`messages`, paged by `(created_at, author, id)` and `(created_at, hash)`
|
||||
cursors, which servers still answer. Gossip lost *while connected* is only
|
||||
repaired by the next reconnect; periodic anti-entropy is future work.
|
||||
- **Reconnection**: bootstrap peers are redialed every 20 s when disconnected.
|
||||
- **Re-announce**: a running node re-gossips its own live listings and
|
||||
@@ -476,7 +493,7 @@ Proof-of-work per listing and per revocation, plus subscribable blocklists
|
||||
|
||||
Abuse reporting for messages, reciprocity rules, anti-
|
||||
discrimination (AGG) content rules, blocklists, peer scoring and rate limits,
|
||||
incremental sync and anti-entropy, a fallback bootstrap list inside the binary
|
||||
periodic anti-entropy while connected, a fallback bootstrap list inside the binary
|
||||
for networks that block DNS, image hosting,
|
||||
recovering listings onto a fresh machine with an empty database, a helper to
|
||||
turn a place name into a region.
|
||||
|
||||
Reference in New Issue
Block a user