From eba718c6debe1130bb1c40daf86132507fc7e4d9 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Fri, 26 Oct 2018 09:17:17 -0400 Subject: [PATCH] Require aiorpcx 0.9.x --- electrumx/server/controller.py | 6 +++--- electrumx/server/peers.py | 10 +++++----- electrumx/server/session.py | 8 ++++---- electrumx_rpc | 4 ++-- setup.py | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/electrumx/server/controller.py b/electrumx/server/controller.py index cfd7bcf..ecbf5b8 100644 --- a/electrumx/server/controller.py +++ b/electrumx/server/controller.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2017, Neil Booth +# Copyright (c) 2016-2018, Neil Booth # # All rights reserved. # @@ -83,8 +83,8 @@ class Controller(ServerBase): '''Start the RPC server and wait for the mempool to synchronize. Then start serving external clients. ''' - if not (0, 8, 1) <= aiorpcx_version < (0, 9): - raise RuntimeError('aiorpcX version 0.8.x with x >= 1 required') + if not (0, 9, 0) <= aiorpcx_version < (0, 10): + raise RuntimeError('aiorpcX version 0.9.x required') env = self.env min_str, max_str = env.coin.SESSIONCLS.protocol_min_max_strings() diff --git a/electrumx/server/peers.py b/electrumx/server/peers.py index e8a7486..4d5059f 100644 --- a/electrumx/server/peers.py +++ b/electrumx/server/peers.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017, Neil Booth +# Copyright (c) 2017-2018, Neil Booth # # All rights reserved. # @@ -14,7 +14,7 @@ import ssl import time from collections import defaultdict, Counter -from aiorpcx import (ClientSession, SOCKSProxy, +from aiorpcx import (Connector, RPCSession, SOCKSProxy, Notification, handler_invocation, SOCKSError, RPCError, TaskTimeout, TaskGroup, Event, sleep, run_in_thread, ignore_after, timeout_after) @@ -37,7 +37,7 @@ def assert_good(message, result, instance): f'{type(result).__name__}') -class PeerSession(ClientSession): +class PeerSession(RPCSession): '''An outgoing session to a peer.''' async def handle_request(self, request): @@ -226,8 +226,8 @@ class PeerManager(object): peer_text = f'[{peer}:{port} {kind}]' try: async with timeout_after(120 if peer.is_tor else 30): - async with PeerSession(peer.host, port, - **kwargs) as session: + async with Connector(PeerSession, peer.host, port, + **kwargs) as session: await self._verify_peer(session, peer) is_good = True break diff --git a/electrumx/server/session.py b/electrumx/server/session.py index 8aac790..35c0d96 100644 --- a/electrumx/server/session.py +++ b/electrumx/server/session.py @@ -20,7 +20,7 @@ from collections import defaultdict from functools import partial from aiorpcx import ( - ServerSession, JSONRPCAutoDetect, JSONRPCConnection, + RPCSession, JSONRPCAutoDetect, JSONRPCConnection, TaskGroup, handler_invocation, RPCError, Request, ignore_after, sleep, Event ) @@ -289,7 +289,7 @@ class SessionManager(object): 'errors': sum(s.errors for s in self.sessions), 'groups': len(group_map), 'logged': len([s for s in self.sessions if s.log_me]), - 'paused': sum(s.paused for s in self.sessions), + 'paused': sum(not s.can_send.is_set() for s in self.sessions), 'pid': os.getpid(), 'peers': self.peer_mgr.info(), 'requests': sum(s.count_pending_items() for s in self.sessions), @@ -593,7 +593,7 @@ class SessionManager(object): self.subs_room -= 1 -class SessionBase(ServerSession): +class SessionBase(RPCSession): '''Base class of ElectrumX JSON sessions. Each session runs its tasks in asynchronous parallelism with other @@ -667,7 +667,7 @@ class SessionBase(ServerSession): super().connection_lost(exc) self.session_mgr.remove_session(self) msg = '' - if self.paused: + if not self.can_send.is_set(): msg += ' whilst paused' if self.concurrency.max_concurrent != self.max_concurrent: msg += ' whilst throttled' diff --git a/electrumx_rpc b/electrumx_rpc index cd7a1ac..09c5585 100755 --- a/electrumx_rpc +++ b/electrumx_rpc @@ -10,7 +10,7 @@ '''Script to send RPC commands to a running ElectrumX server.''' -from aiorpcx import timeout_after, ClientSession, TaskTimeout +from aiorpcx import timeout_after, Connector, RPCSession, TaskTimeout import argparse import asyncio import json @@ -114,7 +114,7 @@ def main(): async def send_request(): try: async with timeout_after(15): - async with ClientSession('localhost', port) as session: + async with Connector(RPCSession, 'localhost', port) as session: result = await session.send_request(method, args) if method in ('query', ): for line in result: diff --git a/setup.py b/setup.py index 4aafdf7..36b6f8a 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setuptools.setup( # "blake256" package is required to sync Decred network. # "xevan_hash" package is required to sync Xuez network. # "groestlcoin_hash" package is required to sync Groestlcoin network. - install_requires=['aiorpcX>=0.8.1,<0.9', 'attrs', + install_requires=['aiorpcX>=0.9.0,<0.10', 'attrs', 'plyvel', 'pylru', 'aiohttp >= 2'], packages=setuptools.find_packages(include=('electrumx*',)), description='ElectrumX Server',