mirror of
https://github.com/logos-messaging/logos-delivery-go.git
synced 2026-06-25 23:59:26 +00:00
fix: reset peer backoff on recovery so reconnect is not blocked (#1308)
Signed-off-by: kblinichkin <kirill.blinichkin@gmail.com>
This commit is contained in:
parent
2ccee74ecb
commit
81291ef862
@ -90,11 +90,13 @@ func (w *WakuNode) startKeepAlive(ctx context.Context, randomPeersPingDuration t
|
||||
lastTimeExecuted = w.timesource.Now()
|
||||
w.log.Warn("keep alive hasnt been executed recently. Killing all connections")
|
||||
disconnectAllPeers(w.host, w.log)
|
||||
w.peerConnector.ResetBackoff()
|
||||
continue
|
||||
} else if iterationFailure >= maxAllowedSubsequentPingFailures {
|
||||
iterationFailure = 0
|
||||
w.log.Warn("Pinging random peers failed, node is likely disconnected. Killing all connections")
|
||||
disconnectAllPeers(w.host, w.log)
|
||||
w.peerConnector.ResetBackoff()
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@ -218,6 +218,16 @@ func (c *PeerConnectionStrategy) canDialPeer(pi peer.AddrInfo) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ResetBackoff clears all accumulated per-peer connection backoffs so that
|
||||
// every known peer can be retried immediately on the next connection attempt.
|
||||
// Call this after a recovery event (e.g. sleep/wake, all pings failed) so that
|
||||
// stale hour-long backoffs do not prevent reconnection once the network is back.
|
||||
func (c *PeerConnectionStrategy) ResetBackoff() {
|
||||
c.mux.Lock()
|
||||
defer c.mux.Unlock()
|
||||
c.cache.Purge()
|
||||
}
|
||||
|
||||
func (c *PeerConnectionStrategy) addConnectionBackoff(peerID peer.ID) {
|
||||
c.mux.Lock()
|
||||
defer c.mux.Unlock()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user