diff --git a/electrumx/lib/server_base.py b/electrumx/lib/server_base.py index 122ddc7..06557b5 100644 --- a/electrumx/lib/server_base.py +++ b/electrumx/lib/server_base.py @@ -23,12 +23,12 @@ class ServerBase(object): Derived classes are expected to: - - set PYTHON_MIN_VERSION and SUPPRESS_MESSAGES as appropriate + - set PYTHON_MIN_VERSION and SUPPRESS_MESSAGE_REGEX as appropriate - implement the serve() coroutine, called from the run() method. Upon return the event loop runs until the shutdown signal is received. ''' - - SUPPRESS_MESSAGE_REGEX = re.compile('SSH handshake') + SUPPRESS_MESSAGE_REGEX = re.compile('SSL handshake|Fatal read error on|' + 'SSL error in data received') SUPPRESS_TASK_REGEX = re.compile('accept_connection2') PYTHON_MIN_VERSION = (3, 6) diff --git a/electrumx/server/peers.py b/electrumx/server/peers.py index 752b329..31e9f74 100644 --- a/electrumx/server/peers.py +++ b/electrumx/server/peers.py @@ -390,9 +390,13 @@ class PeerManager(object): await group.spawn(forever.wait()) await group.spawn(self._detect_proxy()) await group.spawn(self._import_peers()) - # Consume tasks as they complete + # Consume tasks as they complete, logging unexpected failures async for task in group: - task.result() + if not task.cancelled(): + try: + task.result() + except Exception: + self.logger.exception('task failed unexpectedly') def info(self): '''The number of peers.''' diff --git a/electrumx/server/session.py b/electrumx/server/session.py index cbd9a18..3210741 100644 --- a/electrumx/server/session.py +++ b/electrumx/server/session.py @@ -683,8 +683,10 @@ class ElectrumX(SessionBase): # Check mempool hashXs - the status is a function of the # confirmed state of other transactions. Note: we cannot # iterate over mempool_statuses as it changes size. - for hashX in set(self.mempool_statuses): - old_status = self.mempool_statuses[hashX] + for hashX in tuple(self.mempool_statuses): + # Items can be evicted whilst await-ing below; False + # ensures such hashXs are notified + old_status = self.mempool_statuses.get(hashX, False) status = await self.address_status(hashX) if status != old_status: alias = self.hashX_subs[hashX]