URI: 
       tNetworkRetryManager: add random noise to time - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 7257172e1c091cfe63923d3cbd30ded4b63aba25
   DIR parent 76f0ad3271a611457a88e4bfe213334afcf1a5ae
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Wed, 15 Apr 2020 17:23:02 +0200
       
       NetworkRetryManager: add random noise to time
       
       Diffstat:
         M electrum/util.py                    |       6 +++++-
       
       1 file changed, 5 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/electrum/util.py b/electrum/util.py
       t@@ -42,6 +42,7 @@ import time
        from typing import NamedTuple, Optional
        import ssl
        import ipaddress
       +import random
        
        import aiohttp
        from aiohttp_socks import ProxyConnector, ProxyType
       t@@ -1372,7 +1373,10 @@ class NetworkRetryManager(Generic[_NetAddrType]):
        
            def _trying_addr_now(self, addr: _NetAddrType) -> None:
                last_time, num_attempts = self._last_tried_addr.get(addr, (0, 0))
       -        self._last_tried_addr[addr] = time.time(), num_attempts + 1
       +        # we add up to 1 second of noise to the time, so that clients are less likely
       +        # to get synchronised and bombard the remote in connection waves:
       +        cur_time = time.time() + random.random()
       +        self._last_tried_addr[addr] = cur_time, num_attempts + 1
        
            def _on_connection_successfully_established(self, addr: _NetAddrType) -> None:
                self._last_tried_addr[addr] = time.time(), 0