Skip to content

Commit 501d340

Browse files
authored
Merge pull request ethereum#212 from OffchainLabs/config-max-batch-size
Make the RPC max response batch size editable
2 parents 8c5b933 + d52739e commit 501d340

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

rpc/handler.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func newHandler(connCtx context.Context, conn jsonWriter, idgen func() ID, reg *
9292
return h
9393
}
9494

95-
const maxBatchResponseSize int = 10_000_000 // 10MB
95+
var MaxBatchResponseSize int = 10_000_000 // 10MB
9696

9797
// handleBatch executes all messages in a batch and returns the responses.
9898
func (h *handler) handleBatch(msgs []*jsonrpcMessage) {
@@ -126,8 +126,8 @@ func (h *handler) handleBatch(msgs []*jsonrpcMessage) {
126126
return
127127
}
128128
totalSize += len(serialized)
129-
if totalSize > maxBatchResponseSize {
130-
h.conn.writeJSON(cp.ctx, errorMessage(&invalidRequestError{fmt.Sprintf("batch response exceeded limit of %v bytes", maxBatchResponseSize)}))
129+
if MaxBatchResponseSize > 0 && totalSize > MaxBatchResponseSize {
130+
h.conn.writeJSON(cp.ctx, errorMessage(&invalidRequestError{fmt.Sprintf("batch response exceeded limit of %v bytes", MaxBatchResponseSize)}))
131131
return
132132
}
133133
answers = append(answers, serialized)

0 commit comments

Comments
 (0)