Browse Source

network: make MAX_INCOMING_MSG_SIZE configurable from config

requested in https://github.com/spesmilo/electrum/issues/4315#issuecomment-698730778
patch-4
SomberNight 4 years ago
parent
commit
5a7c3dc4d0
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 11
      electrum/interface.py

11
electrum/interface.py

@ -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…
Cancel
Save