@@ -95,7 +95,7 @@ func New(
95
95
blockLister : blockLister ,
96
96
rate : rate .New (DefaultHistRateWindow ),
97
97
cancel : func () { /* Noop, since the context is initialized in the Start(). */ },
98
- limiter : ratelimit .NewLimiter (ratelimit .Every (time .Second ), int (swarm .MaxBins )), // allows for 1 sync per second, max bins bursts
98
+ limiter : ratelimit .NewLimiter (ratelimit .Every (time .Second / 2 ), int (swarm .MaxBins )), // allows for 2 syncs per second, max bins bursts
99
99
}
100
100
101
101
return p
@@ -305,8 +305,15 @@ func (p *Puller) syncWorker(ctx context.Context, peer swarm.Address, bin uint8,
305
305
306
306
for {
307
307
308
- // rate limit within neighborhood
309
- if bin >= p .radius .StorageRadius () {
308
+ s , _ , _ , err := p .nextPeerInterval (peer , bin )
309
+ if err != nil {
310
+ p .metrics .SyncWorkerErrCounter .Inc ()
311
+ p .logger .Error (err , "syncWorker nextPeerInterval failed, quitting" )
312
+ return
313
+ }
314
+
315
+ // rate limit historical syncing
316
+ if s <= cur {
310
317
_ = p .limiter .Wait (ctx )
311
318
}
312
319
@@ -319,13 +326,6 @@ func (p *Puller) syncWorker(ctx context.Context, peer swarm.Address, bin uint8,
319
326
320
327
p .metrics .SyncWorkerIterCounter .Inc ()
321
328
322
- s , _ , _ , err := p .nextPeerInterval (peer , bin )
323
- if err != nil {
324
- p .metrics .SyncWorkerErrCounter .Inc ()
325
- p .logger .Error (err , "syncWorker nextPeerInterval failed, quitting" )
326
- return
327
- }
328
-
329
329
syncStart := time .Now ()
330
330
top , count , err := p .syncer .Sync (ctx , peer , bin , s )
331
331
0 commit comments