Skip to content

Commit 3ccfda2

Browse files
committed
fixes
1 parent cb212d6 commit 3ccfda2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/sync/sync_service.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ func (syncService *SyncService[H]) initFromP2PWithRetry(ctx context.Context, pee
364364
backoff := 1 * time.Second
365365
maxBackoff := 10 * time.Second
366366

367-
timeoutTimer := time.NewTimer(time.Minute * 5)
367+
timeoutTimer := time.NewTimer(time.Minute * 2)
368368
defer timeoutTimer.Stop()
369369

370370
for {
@@ -400,6 +400,13 @@ func (syncService *SyncService[H]) retryInitInBackground() {
400400
maxBackoff := 5 * time.Minute
401401

402402
for {
403+
select {
404+
case <-syncService.bgCtx.Done():
405+
syncService.logger.Info().Msg("background retry cancelled")
406+
return
407+
case <-time.After(backoff):
408+
}
409+
403410
ok, err := syncService.tryInit(syncService.bgCtx)
404411
if ok {
405412
syncService.logger.Info().Msg("successfully initialized store from P2P in background")
@@ -408,13 +415,6 @@ func (syncService *SyncService[H]) retryInitInBackground() {
408415

409416
syncService.logger.Info().Err(err).Dur("retry_in", backoff).Msg("background retry: headers not yet available from peers")
410417

411-
select {
412-
case <-syncService.bgCtx.Done():
413-
syncService.logger.Info().Msg("background retry cancelled")
414-
return
415-
case <-time.After(backoff):
416-
}
417-
418418
backoff *= 2
419419
if backoff > maxBackoff {
420420
backoff = maxBackoff

0 commit comments

Comments
 (0)