sync: a page is stored in one transaction with parallel verification; a sync is cut off by idleness, not a fixed 2 minutes

20,000 listings to a newcomer: 120 s (unfinished) -> 24 s.

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 09:46:27 +01:00
co-authored by Claude Sonnet 5.5
parent fc3a1efba4
commit 7da38a9e7e
8 changed files with 352 additions and 29 deletions
+5 -5
View File
@@ -45,6 +45,7 @@ func (n *Node) recoverOwn(ctx context.Context, p peer.ID) error {
for page := 0; page < maxSyncPages; page++ {
var count int
var last string
var got []*listing.Listing
err := n.request(ctx, p, syncRequest{
Kind: "author", Author: author, Limit: n.cfg.SyncPageSize, AfterID: after,
}, func(line []byte) {
@@ -57,12 +58,11 @@ func (n *Node) recoverOwn(ctx context.Context, p peer.ID) error {
if l.Author != author {
return // peer sent something we did not ask for
}
if out, err := n.cfg.Store.Put(ctx, &l); err != nil {
n.log.Debug("recover: listing rejected", "peer", p, "err", err)
} else {
n.noteListing(ctx, &l, out, "recover", p)
}
got = append(got, &l)
})
if serr := n.storeSynced(ctx, p, "recover", got); serr != nil {
return serr
}
if err != nil {
n.recoverAsked.Add(-1) // this peer could not answer; another may
return err