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
+14
View File
@@ -157,6 +157,20 @@ func (s *Store) ListingsByKey(ctx context.Context, keys []string) ([]*listing.Li
return out, nil
}
// AuthorListings returns up to limit unexpired records (deletions included)
// signed by author, in id order, after afterID. A node that lost its database
// asks its peers for these to get its own listings back.
func (s *Store) AuthorListings(ctx context.Context, author, afterID string, limit int) ([]*listing.Listing, error) {
rows, err := s.db.QueryContext(ctx, `
SELECT data FROM listings
WHERE author = ? AND id > ? AND expires_at > ?
ORDER BY id LIMIT ?`, author, afterID, s.clock().Unix(), limit)
if err != nil {
return nil, err
}
return collect(rows)
}
// RevocationDigest digests the relevant revocations (see Revocations).
func (s *Store) RevocationDigest(ctx context.Context) (Digest, error) {
rows, err := s.db.QueryContext(ctx, `