mirror of
https://github.com/ACINQ/eclair.git
synced 2025-03-13 19:37:35 +01:00
Peer: use a minimum reconnection delay of 200 ms (#1285)
If our initial random deconnnection delay is 0 (unlikely but possible) then all "exponential backoff" reconnection delays will be 0 too, so we set a minimum value of 200 milliseconds.
(cherry picked from commit a0ae5ef13f
)
This commit is contained in:
parent
1a8f225d76
commit
e3f6f08631
2 changed files with 2 additions and 1 deletions
|
@ -719,7 +719,7 @@ object Peer {
|
|||
/**
|
||||
* This helps preventing peers reconnection loops due to synchronization of reconnection attempts.
|
||||
*/
|
||||
def randomizeDelay(initialRandomReconnectDelay: FiniteDuration): FiniteDuration = Random.nextInt(initialRandomReconnectDelay.toMillis.toInt).millis
|
||||
def randomizeDelay(initialRandomReconnectDelay: FiniteDuration): FiniteDuration = Random.nextInt(initialRandomReconnectDelay.toMillis.toInt).millis.max(200 milliseconds)
|
||||
|
||||
/**
|
||||
* Exponential backoff retry with a finite max
|
||||
|
|
|
@ -199,6 +199,7 @@ class PeerSpec extends TestkitBaseClass with StateTestsHelperMethods {
|
|||
probe.send(transport.ref, PoisonPill)
|
||||
awaitCond(peer.stateName === DISCONNECTED)
|
||||
val initialReconnectDelay = peer.stateData.asInstanceOf[DisconnectedData].nextReconnectionDelay
|
||||
assert(initialReconnectDelay >= (200 milliseconds))
|
||||
assert(initialReconnectDelay <= (10 seconds))
|
||||
probe.send(peer, Reconnect)
|
||||
assert(peer.stateData.asInstanceOf[DisconnectedData].nextReconnectionDelay === (initialReconnectDelay * 2))
|
||||
|
|
Loading…
Add table
Reference in a new issue