From 01981f71fba61190422a4b6bb682bfc12d4200b8 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 3 Mar 2020 21:04:54 +0100 Subject: [PATCH] lnworker.add_peer: don't block event loop with DNS --- electrum/lnworker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 9e9f45b90..f52d61ae6 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -857,8 +857,11 @@ class LNWallet(LNWorker): if not addrs: raise ConnStringFormatError(_('Don\'t know any addresses for node:') + ' ' + bh2u(node_id)) host, port, timestamp = self.choose_preferred_address(addrs) + port = int(port) + # Try DNS-resolving the host (if needed). This is simply so that + # the caller gets a nice exception if it cannot be resolved. try: - socket.getaddrinfo(host, int(port)) + await asyncio.get_event_loop().getaddrinfo(host, port) except socket.gaierror: raise ConnStringFormatError(_('Hostname does not resolve (getaddrinfo failed)')) # add peer