From 35a8812534df2ab2667824f7dc1a9a2b3bb1bd78 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 6 Mar 2020 15:13:18 +0100 Subject: [PATCH] lnworker.reestablish_peer_for_given_channel: give each addr a chance follow-up fa0ef9c5481861484b504dab5c7eb703c5edb49f --- electrum/lnworker.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 3d53cf3d6..dab4c6a41 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1336,7 +1336,15 @@ class LNWallet(LNWorker): peer_addresses.append(LNPeerAddr(host, port, chan.node_id)) # will try addresses stored in channel storage peer_addresses += list(chan.get_peer_addresses()) - # now select first one that has not failed recently + # Now select first one that has not failed recently. + # Use long retry interval to check. This ensures each address we gathered gets a chance. + for peer in peer_addresses: + last_tried = self._last_tried_peer.get(peer, 0) + if last_tried + PEER_RETRY_INTERVAL < now: + await self._add_peer(peer.host, peer.port, peer.pubkey) + return + # Still here? That means all addresses failed ~recently. + # Use short retry interval now. for peer in peer_addresses: last_tried = self._last_tried_peer.get(peer, 0) if last_tried + PEER_RETRY_INTERVAL_FOR_CHANNELS < now: