align maximum body size between Websock and HTTP transports (#211)

HTTP has a 128 MB limit, while websock uses the library default (20 MB).
Align both to 128 MB. This should be enough for an Ethereum `getPayload`
with 6 blobs, all hex encoded binary + JSON overhead.
This commit is contained in:
Etan Kissling 2024-02-20 14:34:20 +01:00 committed by GitHub
parent 9c65df3053
commit 8682bb6c85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 6 deletions

View File

@ -28,6 +28,8 @@ export
ResponseBatchRx,
results
const MaxMessageBodyBytes* = 128 * 1024 * 1024 # 128 MB (JSON encoded)
type
RpcBatchItem* = object
meth*: string

View File

@ -33,9 +33,6 @@ type
maxBodySize: int
getHeaders: GetJsonRpcRequestHeaders
const
MaxHttpRequestSize = 128 * 1024 * 1024 # maximum size of HTTP body in octets
{.push gcsafe, raises: [].}
# ------------------------------------------------------------------------------
@ -43,7 +40,7 @@ const
# ------------------------------------------------------------------------------
proc new(
T: type RpcHttpClient, maxBodySize = MaxHttpRequestSize, secure = false,
T: type RpcHttpClient, maxBodySize = MaxMessageBodyBytes, secure = false,
getHeaders: GetJsonRpcRequestHeaders = nil, flags: HttpClientFlags = {}): T =
var moreFlags: HttpClientFlags
@ -132,7 +129,7 @@ proc callImpl(client: RpcHttpClient, reqBody: string): Future[string] {.async.}
# ------------------------------------------------------------------------------
proc newRpcHttpClient*(
maxBodySize = MaxHttpRequestSize, secure = false,
maxBodySize = MaxMessageBodyBytes, secure = false,
getHeaders: GetJsonRpcRequestHeaders = nil,
flags: HttpClientFlags = {}): RpcHttpClient =
RpcHttpClient.new(maxBodySize, secure, getHeaders, flags)

View File

@ -84,7 +84,7 @@ proc processData(client: RpcWebSocketClient) {.async.} =
let ws = client.transport
try:
while ws.readyState != ReadyState.Closed:
var value = await ws.recvMsg()
var value = await ws.recvMsg(MaxMessageBodyBytes)
if value.len == 0:
# transmission ends