p2p: a node asks its peers for its own listings after losing its database

Sync kind 'author': everything a peer holds from one author key, any region.
A node asks the first 3 peers it syncs with per run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-19 08:03:10 +01:00
co-authored by Claude Sonnet 5.5
parent 2f89a599e3
commit 1f1f649800
7 changed files with 204 additions and 4 deletions
+11
View File
@@ -169,6 +169,17 @@ within 30 days.
up to 3 rounds and 24 dials. Old nodes
do not know the kind and ignore it. The peer cache records which of the
node's regions a peer was seen in, and a restart redials those first.
- **Getting your own listings back** (`internal/p2p/recover.go`): a node that
starts on an empty or old database (lost disk, restore from the phrase) asks
the first 3 peers it syncs with for everything signed by its own author key
(sync request `{"kind":"author","author":<64 hex>}`, paged by id; deletions
included, expired records not). Region sync only brings back the regions the
node follows; this also finds the rest, and it restores the newest `seq` of
each listing, without which an edit after the restore would lose against the
copy the network holds. Only peers that hold the listings can answer, which
means peers that follow the listing's region; a listing that no connected
peer holds cannot be found this way. Listings are public, so any peer may
ask for any author's. Old nodes do not know the kind and ignore it.
- **Reconnection**: bootstrap peers are redialed every 20 s when disconnected.
- **Re-announce**: a running node re-gossips its own live listings and
revocations every 30 minutes, so newcomers hear about them without waiting