Browse Source

ChannelDB: fix get_last_good_address

patch-4
SomberNight 4 years ago
parent
commit
9a803cd1d6
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 5
      electrum/channel_db.py

5
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:

Loading…
Cancel
Save