electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 9a803cd1d683b72a2246ed70d76f77562f8d9981
parent b3a84e3137c020db5795cafda9daae95ee1c345f
Author: SomberNight <somber.night@protonmail.com>
Date:   Sat,  9 Jan 2021 18:41:41 +0100

ChannelDB: fix get_last_good_address

Diffstat:
Melectrum/channel_db.py | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/electrum/channel_db.py b/electrum/channel_db.py @@ -334,11 +334,12 @@ class ChannelDB(SqlDB): unshuffled = set(self._nodes.keys()) - node_ids return random.sample(unshuffled, min(200, len(unshuffled))) - def get_last_good_address(self, node_id) -> Optional[LNPeerAddr]: + def get_last_good_address(self, node_id: bytes) -> Optional[LNPeerAddr]: + """Returns latest address we successfully connected to, for given node.""" r = self._addresses.get(node_id) if not r: return None - addr = sorted(list(r), key=lambda x: x.timestamp)[0] + addr = sorted(list(r), key=lambda x: x.timestamp, reverse=True)[0] try: return LNPeerAddr(addr.host, addr.port, node_id) except ValueError: