electrum

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

commit 7a46bd10893b30779ba180442ab60495a416fd6c
parent 908c9793385650aefe1f82b3c6a46e3be32b96cc
Author: SomberNight <somber.night@protonmail.com>
Date:   Sat,  3 Nov 2018 17:11:08 +0100

network: minor clean-up

Diffstat:
Melectrum/network.py | 31++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/electrum/network.py b/electrum/network.py @@ -382,7 +382,11 @@ class Network(PrintError): def get_parameters(self) -> NetworkParameters: host, port, protocol = deserialize_server(self.default_server) - return NetworkParameters(host, port, protocol, self.proxy, self.auto_connect) + return NetworkParameters(host=host, + port=port, + protocol=protocol, + proxy=self.proxy, + auto_connect=self.auto_connect) def get_donation_address(self): if self.is_connected(): @@ -487,15 +491,16 @@ class Network(PrintError): try: deserialize_server(serialize_server(host, port, protocol)) if proxy: - proxy_modes.index(proxy["mode"]) + 1 + proxy_modes.index(proxy['mode']) + 1 int(proxy['port']) except: return self.config.set_key('auto_connect', net_params.auto_connect, False) - self.config.set_key("proxy", proxy_str, False) - self.config.set_key("server", server_str, True) + self.config.set_key('proxy', proxy_str, False) + self.config.set_key('server', server_str, True) # abort if changes were not allowed by config - if self.config.get('server') != server_str or self.config.get('proxy') != proxy_str: + if self.config.get('server') != server_str \ + or self.config.get('proxy') != proxy_str: return async with self.restart_lock: @@ -796,6 +801,14 @@ class Network(PrintError): async def _start(self): assert not self.main_taskgroup self.main_taskgroup = SilentTaskGroup() + assert not self.interface and not self.interfaces + assert not self.connecting and not self.server_queue + self.print_error('starting network') + self.disconnected_servers = set([]) + self.protocol = deserialize_server(self.default_server)[2] + self.server_queue = queue.Queue() + self._set_proxy(deserialize_proxy(self.config.get('proxy'))) + self._start_interface(self.default_server) async def main(): try: @@ -808,14 +821,6 @@ class Network(PrintError): raise e asyncio.run_coroutine_threadsafe(main(), self.asyncio_loop) - assert not self.interface and not self.interfaces - assert not self.connecting and not self.server_queue - self.print_error('starting network') - self.disconnected_servers = set([]) - self.protocol = deserialize_server(self.default_server)[2] - self.server_queue = queue.Queue() - self._set_proxy(deserialize_proxy(self.config.get('proxy'))) - self._start_interface(self.default_server) self.trigger_callback('network_updated') def start(self, jobs: List=None):