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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user