Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
arijitAD committed Jun 8, 2021
1 parent 1b7ae67 commit ed283b1
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions dot/network/connmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,34 @@ func (cm *ConnManager) Disconnected(n network.Network, c network.Conn) {
Addrs: addrs,
}

count := 0
retry := func() bool {
err := cm.host.connect(info)
if err != nil {
logger.Warn("failed to reconnect to persistent peer", "peer", c.RemotePeer(), "error", err)
return false
}

count++
if count > maxRetries {
return true
}
return true
}

go func() {
retry := 0
if retry() {
return
}

retryTimer := time.NewTicker(time.Minute)
defer retryTimer.Stop()
for {
select {
case <-cm.host.ctx.Done():
return
case <-retryTimer.C:
err := cm.host.connect(info)
if err != nil {
logger.Warn("failed to reconnect to persistent peer", "peer", c.RemotePeer(), "error", err)
continue
}

retry++
if retry > maxRetries {
if retry() {
return
}
}
Expand Down

0 comments on commit ed283b1

Please sign in to comment.