Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSS][cs-6.40]: Node and Server Use json.MarshalIndent in Wire Formats Minor #1209

Closed
abelliumnt opened this issue Jul 1, 2023 · 0 comments
Assignees

Comments

@abelliumnt
Copy link
Collaborator

Describe the bug

json.MarshalIndent adds indents to the serialized json struct which unnecessarily increases the size of the message on the wire.

tss/ws/server/handler.go:L497-L503

case msg := <-wsc.requestChan:
	wsc.Logger.Info("send msg from requestChan to target client", "method", msg.Method)
	jsonBytes, err := json.MarshalIndent(msg, "", "  ")
	if err != nil {
		wsc.Logger.Error("Failed to marshal RPCRequest to JSON", "err", err)
		continue
	}

tss/node/server/http.go:L189-L195

jsonResult, err := json.MarshalIndent(signResp, "", "	")
if err != nil {
	hs.logger.Error().Err(err).Msg("fail to marshal response to json message")
	w.WriteHeader(http.StatusInternalServerError)
	return
}

Expected behavior
To enhance the efficiency of message transmission, it’s recommended to replace json.MarshalIndent with json.Marshal. Moreover, a switch to a more efficient wire format, such as a binary one, could significantly improve data transmission efficiency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant