Browse Source

statesync: add logging while waiting for peers (#7007)

pull/7013/head
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
9a16d930c6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions
  1. +12
    -0
      internal/statesync/reactor.go

+ 12
- 0
internal/statesync/reactor.go View File

@ -1006,7 +1006,11 @@ func (r *Reactor) waitForEnoughPeers(ctx context.Context, numPeers int) error {
startAt := time.Now()
t := time.NewTicker(100 * time.Millisecond)
defer t.Stop()
logT := time.NewTicker(time.Minute)
defer logT.Stop()
var iter int
for r.peers.Len() < numPeers {
iter++
select {
case <-ctx.Done():
return fmt.Errorf("operation canceled while waiting for peers after %s", time.Since(startAt))
@ -1014,6 +1018,14 @@ func (r *Reactor) waitForEnoughPeers(ctx context.Context, numPeers int) error {
return fmt.Errorf("shutdown while waiting for peers after %s", time.Since(startAt))
case <-t.C:
continue
case <-logT.C:
r.Logger.Info("waiting for sufficient peers to start statesync",
"duration", time.Since(startAt).String(),
"target", numPeers,
"peers", r.peers.Len(),
"iters", iter,
)
continue
}
}
return nil


Loading…
Cancel
Save