tStyle cleanups. - obelisk - Electrum server using libbitcoin as its backend HTML git clone https://git.parazyd.org/obelisk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 0c8ef25aea1b5e0bab605b950f77d93279861c9b DIR parent 4bd137d749e08644979fdbc53726a6cac578ea00 HTML Author: parazyd <parazyd@dyne.org> Date: Mon, 19 Apr 2021 16:17:00 +0200 Style cleanups. Diffstat: M obelisk/protocol.py | 19 ++++++++++--------- M obelisk/zeromq.py | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) --- DIR diff --git a/obelisk/protocol.py b/obelisk/protocol.py t@@ -112,11 +112,11 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902 self.log.debug("ElectrumProtocol.stop()") self.stopped = True if self.bx: - unsub_pool = [] - for i in self.sh_subscriptions: # pragma: no cover - self.log.debug("bx.unsubscribe %s", i) - unsub_pool.append(self.bx.unsubscribe_scripthash(i)) - await asyncio.gather(*unsub_pool, return_exceptions=True) + # unsub_pool = [] + # for i in self.sh_subscriptions: # pragma: no cover + # self.log.debug("bx.unsubscribe %s", i) + # unsub_pool.append(self.bx.unsubscribe_scripthash(i)) + # await asyncio.gather(*unsub_pool, return_exceptions=True) await self.bx.stop() # idxs = [] t@@ -470,15 +470,16 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902 if _ec and _ec != 0: return JsonRPCError.internalerror() - task = asyncio.create_task(self.scripthash_notifier(writer, scripthash)) - self.sh_subscriptions[scripthash] = {"task": task} - if len(history) < 1: return {"result": None} # TODO: Check how history4 acts for mempool/unconfirmed status = ElectrumProtocol.__scripthash_status_from_history(history) - self.sh_subscriptions[scripthash]["status"] = status + self.sh_subscriptions[scripthash] = {"status": status} + + task = asyncio.create_task(self.scripthash_notifier(writer, scripthash)) + self.sh_subscriptions[scripthash]["task"] = task + return {"result": ElectrumProtocol.__scripthash_status_encode(status)} @staticmethod DIR diff --git a/obelisk/zeromq.py b/obelisk/zeromq.py t@@ -268,7 +268,7 @@ class Client: async def _subscription_request(self, command, data): request = await self._request(command, data) - request.queue = asyncio.Queue(loop=self._settings._loop) # pylint: disable=W0212 + request.queue = asyncio.Queue() error_code, _ = await self._wait_for_response(request) return error_code, request.queue t@@ -353,8 +353,6 @@ class Client: async def unsubscribe_scripthash(self, scripthash): """Unsubscribe scripthash""" - # TODO: This call should ideally also remove the subscription - # request from the RequestCollection. # This call solicits a final call from the server with an # `error::service_stopped` error code. command = b"unsubscribe.key" t@@ -390,6 +388,8 @@ class Client: # self.log.debug("history correlated: %s", correlated_points) # BUG: In libbitcoin v4 sometimes transactions mess up and double + # https://github.com/libbitcoin/libbitcoin-server/issues/545 + # # The following is not a very efficient solution correlated = [ i for n, i in enumerate(correlated_points)