mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 00:41:31 +00:00
move get_index from network to session
This commit is contained in:
parent
e829d6bbcf
commit
8b8ca14c6d
2 changed files with 7 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue