Skip to content

Commit

Permalink
Allocate less per RPC request
Browse files Browse the repository at this point in the history
  • Loading branch information
joshklop committed Sep 20, 2023
1 parent 523bc11 commit a5a1a20
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jsonrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const (
MethodNotFound = -32601 // The method does not exist / is not available.
InvalidParams = -32602 // Invalid method parameter(s).
InternalError = -32603 // Internal JSON-RPC error.

bufferSize = 16
)

var (
Expand Down Expand Up @@ -268,7 +270,7 @@ func (s *Server) Handle(ctx context.Context, conn io.ReadWriter) error {
// It returns the response in a byte array, only returns an
// error if it can not create the response byte array
func (s *Server) handle(ctx context.Context, conn io.ReadWriter) ([]byte, error) {
bufferedReader := bufio.NewReader(conn)
bufferedReader := bufio.NewReaderSize(conn, bufferSize)
requestIsBatch := isBatch(bufferedReader)
res := &response{
Version: "2.0",
Expand Down

0 comments on commit a5a1a20

Please sign in to comment.