From 2f1d08e417c39798d83ced9ca424954381ed1680 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 20 Feb 2020 14:11:16 -0500 Subject: [PATCH] add MAX_RECEIVE wallet server setting --- lbry/wallet/server/env.py | 1 + lbry/wallet/server/session.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lbry/wallet/server/env.py b/lbry/wallet/server/env.py index 80b4c3e1f..4d766b416 100644 --- a/lbry/wallet/server/env.py +++ b/lbry/wallet/server/env.py @@ -76,6 +76,7 @@ class Env: self.donation_address = self.default('DONATION_ADDRESS', '') # Server limits to help prevent DoS self.max_send = self.integer('MAX_SEND', 1000000) + self.max_receive = self.integer('MAX_RECEIVE', 1000000) self.max_subs = self.integer('MAX_SUBS', 250000) self.max_sessions = self.sane_max_sessions() self.max_session_subs = self.integer('MAX_SESSION_SUBS', 50000) diff --git a/lbry/wallet/server/session.py b/lbry/wallet/server/session.py index 3eee3f0f5..a8d59b0c9 100644 --- a/lbry/wallet/server/session.py +++ b/lbry/wallet/server/session.py @@ -30,6 +30,7 @@ from lbry.wallet.server.metrics import ServerLoadData, APICallMetrics from lbry.wallet.server.prometheus import REQUESTS_COUNT, SQLITE_INTERRUPT_COUNT, SQLITE_INTERNAL_ERROR_COUNT from lbry.wallet.server.prometheus import SQLITE_OPERATIONAL_ERROR_COUNT, SQLITE_EXECUTOR_TIMES, SESSIONS_COUNT from lbry.wallet.server.prometheus import SQLITE_PENDING_COUNT, CLIENT_VERSIONS +from lbry.wallet.rpc.framing import NewlineFramer import lbry.wallet.server.version as VERSION from lbry.wallet.rpc import ( @@ -621,6 +622,7 @@ class SessionBase(RPCSession): def __init__(self, session_mgr, db, mempool, peer_mgr, kind): connection = JSONRPCConnection(JSONRPCAutoDetect) + self.env = session_mgr.env super().__init__(connection=connection) self.logger = util.class_logger(__name__, self.__class__.__name__) self.session_mgr = session_mgr @@ -628,7 +630,6 @@ class SessionBase(RPCSession): self.mempool = mempool self.peer_mgr = peer_mgr self.kind = kind # 'RPC', 'TCP' etc. - self.env = session_mgr.env self.coin = self.env.coin self.anon_logs = self.env.anon_logs self.txs_sent = 0 @@ -641,6 +642,9 @@ class SessionBase(RPCSession): async def notify(self, touched, height_changed): pass + def default_framer(self): + return NewlineFramer(self.env.max_receive) + def peer_address_str(self, *, for_log=True): """Returns the peer's IP address and port as a human-readable string, respecting anon logs if the output is for a log."""