commit 1f7b56b455142a545386e38fa4ef905a615031e3
parent 6aa81a8f56309e91f097f78a2420ec569a5716ab
Author: SomberNight <somber.night@protonmail.com>
Date: Sat, 9 Mar 2019 17:13:06 +0100
labels plugin: no need for 'proxy_set' callback
Diffstat:
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/electrum/plugins/labels/labels.py b/electrum/plugins/labels/labels.py
@@ -10,6 +10,8 @@ from electrum.plugin import BasePlugin, hook
from electrum.crypto import aes_encrypt_with_iv, aes_decrypt_with_iv
from electrum.i18n import _
from electrum.util import log_exceptions, ignore_exceptions, make_aiohttp_session
+from electrum.network import Network
+
class LabelsPlugin(BasePlugin):
@@ -17,7 +19,6 @@ class LabelsPlugin(BasePlugin):
BasePlugin.__init__(self, parent, config, name)
self.target_host = 'labels.electrum.org'
self.wallets = {}
- self.proxy = None
def encode(self, wallet, msg):
password, iv, wallet_id = self.wallets[wallet]
@@ -65,13 +66,17 @@ class LabelsPlugin(BasePlugin):
async def do_get(self, url = "/labels"):
url = 'https://' + self.target_host + url
- async with make_aiohttp_session(self.proxy) as session:
+ network = Network.get_instance()
+ proxy = network.proxy if network else None
+ async with make_aiohttp_session(proxy) as session:
async with session.get(url) as result:
return await result.json()
async def do_post(self, url = "/labels", data=None):
url = 'https://' + self.target_host + url
- async with make_aiohttp_session(self.proxy) as session:
+ network = Network.get_instance()
+ proxy = network.proxy if network else None
+ async with make_aiohttp_session(proxy) as session:
async with session.post(url, json=data) as result:
try:
return await result.json()
@@ -160,14 +165,6 @@ class LabelsPlugin(BasePlugin):
self.wallets[wallet] = (password, iv, wallet_id)
# If there is an auth token we can try to actually start syncing
asyncio.run_coroutine_threadsafe(self.pull_safe_thread(wallet, False), wallet.network.asyncio_loop)
- self.proxy = wallet.network.proxy
- wallet.network.register_callback(self.set_proxy, ['proxy_set'])
def stop_wallet(self, wallet):
- if not wallet.network: return # 'offline' mode
- wallet.network.unregister_callback('proxy_set')
self.wallets.pop(wallet, None)
-
- def set_proxy(self, evt_name, new_proxy):
- self.proxy = new_proxy
- self.print_error("proxy set")