tChannelDB: fix get_last_good_address - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 9a803cd1d683b72a2246ed70d76f77562f8d9981 DIR parent b3a84e3137c020db5795cafda9daae95ee1c345f HTML Author: SomberNight <somber.night@protonmail.com> Date: Sat, 9 Jan 2021 18:41:41 +0100 ChannelDB: fix get_last_good_address Diffstat: M electrum/channel_db.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- DIR diff --git a/electrum/channel_db.py b/electrum/channel_db.py t@@ -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: