follow-up prev

This commit is contained in:
SomberNight 2019-10-15 15:41:18 +02:00
parent 38622c0a99
commit 106bc6d2b2
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9
2 changed files with 5 additions and 4 deletions

View file

@ -250,7 +250,8 @@ class ChannelDB(SqlDB):
self._channels = {} # type: Dict[bytes, ChannelInfo]
self._policies = {}
self._nodes = {}
self._addresses = defaultdict(set)
# node_id -> (host, port, ts)
self._addresses = defaultdict(set) # type: Dict[bytes, Set[Tuple[str, int, int]]]
self._channels_for_node = defaultdict(set)
self.data_loaded = asyncio.Event()
self.network = network # only for callback

View file

@ -251,7 +251,7 @@ class LNWorker(Logger):
return peers
@staticmethod
def choose_preferred_address(addr_list: List[Tuple[str, int]]) -> Tuple[str, int]:
def choose_preferred_address(addr_list: Sequence[Tuple[str, int, int]]) -> Tuple[str, int, int]:
assert len(addr_list) >= 1
# choose first one that is an IP
for host, port, timestamp in addr_list:
@ -793,9 +793,9 @@ class LNWallet(LNWorker):
host, port = split_host_port(rest)
else:
addrs = self.channel_db.get_node_addresses(node_id)
if len(addrs) == 0:
if not addrs:
raise ConnStringFormatError(_('Don\'t know any addresses for node:') + ' ' + bh2u(node_id))
host, port, _ = self.choose_preferred_address(addrs)
host, port, timestamp = self.choose_preferred_address(addrs)
try:
socket.getaddrinfo(host, int(port))
except socket.gaierror: