mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 08:51:32 +00:00
network: make MAX_INCOMING_MSG_SIZE configurable from config
requested in https://github.com/spesmilo/electrum/issues/4315#issuecomment-698730778
This commit is contained in:
parent
52bd0eb1a6
commit
5a7c3dc4d0
1 changed files with 7 additions and 4 deletions
|
@ -126,13 +126,13 @@ def assert_list_or_tuple(val: Any) -> None:
|
|||
|
||||
class NotificationSession(RPCSession):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, *args, interface: 'Interface', **kwargs):
|
||||
super(NotificationSession, self).__init__(*args, **kwargs)
|
||||
self.subscriptions = defaultdict(list)
|
||||
self.cache = {}
|
||||
self.default_timeout = NetworkTimeout.Generic.NORMAL
|
||||
self._msg_counter = itertools.count(start=1)
|
||||
self.interface = None # type: Optional[Interface]
|
||||
self.interface = interface # type: Interface
|
||||
self.cost_hard_limit = 0 # disable aiorpcx resource limits
|
||||
|
||||
async def handle_request(self, request):
|
||||
|
@ -209,7 +209,9 @@ class NotificationSession(RPCSession):
|
|||
|
||||
def default_framer(self):
|
||||
# overridden so that max_size can be customized
|
||||
return NewlineFramer(max_size=MAX_INCOMING_MSG_SIZE)
|
||||
max_size = int(self.interface.network.config.get('network_max_incoming_msg_size',
|
||||
MAX_INCOMING_MSG_SIZE))
|
||||
return NewlineFramer(max_size=max_size)
|
||||
|
||||
|
||||
class NetworkException(Exception): pass
|
||||
|
@ -605,7 +607,8 @@ class Interface(Logger):
|
|||
return self.network.default_server == self.server
|
||||
|
||||
async def open_session(self, sslc, exit_early=False):
|
||||
async with _RSClient(session_factory=NotificationSession,
|
||||
session_factory = lambda *args, iface=self, **kwargs: NotificationSession(*args, **kwargs, interface=iface)
|
||||
async with _RSClient(session_factory=session_factory,
|
||||
host=self.host, port=self.port,
|
||||
ssl=sslc, proxy=self.proxy) as session:
|
||||
self.session = session # type: NotificationSession
|
||||
|
|
Loading…
Add table
Reference in a new issue