diff --git a/electrum/interface.py b/electrum/interface.py index da2e08ad8..1d165f6f0 100644 --- a/electrum/interface.py +++ b/electrum/interface.py @@ -54,7 +54,7 @@ class NotificationSession(ClientSession): # will catch the exception, count errors, and at some point disconnect if isinstance(request, Notification): params, result = request.args[:-1], request.args[-1] - key = request.method + repr(params) + key = self.get_index(request.method, params) if key in self.subscriptions: self.cache[key] = result for queue in self.subscriptions[key]: @@ -70,7 +70,7 @@ class NotificationSession(ClientSession): timeout) async def subscribe(self, method, params, queue): - key = method + repr(params) + key = self.get_index(method, params) if key in self.subscriptions: self.subscriptions[key].append(queue) result = self.cache[key] @@ -88,6 +88,11 @@ class NotificationSession(ClientSession): if queue in v: v.remove(queue) + @classmethod + def get_index(cls, method, params): + """Hashable index for subscriptions and cache""" + return str(method) + repr(params) + # FIXME this is often raised inside a TaskGroup, but then it's not silent :( class GracefulDisconnect(AIOSafeSilentException): pass diff --git a/electrum/network.py b/electrum/network.py index 20ebde59a..06d33935f 100644 --- a/electrum/network.py +++ b/electrum/network.py @@ -598,11 +598,6 @@ class Network(PrintError): self.recent_servers = self.recent_servers[0:20] self.save_recent_servers() - @classmethod - def get_index(cls, method, params): - """ hashable index for subscriptions and cache""" - return str(method) + (':' + str(params[0]) if params else '') - @with_interface_lock def connection_down(self, server): '''A connection to server either went down, or was never made.