mirror of
https://github.com/tendermint/tendermint.git
synced 2025-12-23 06:15:19 +00:00
* Remove useless whitespace in Websocket output (#9720) * First try at #9696 * Brief explanation * Removed all prettified JSON RPC responses * Fixes for failing tests. Adapted the assertions in - TestWriteRPCResponseHTTP - TestWriteRPCResponseHTTPError to work with non-pretty JSON-RPC output * Added changelog pending entry * Update CHANGELOG_PENDING.md Co-authored-by: Thane Thomson <connect@thanethomson.com> * Add pending changelog and upgrading entries Signed-off-by: Thane Thomson <connect@thanethomson.com> Signed-off-by: Thane Thomson <connect@thanethomson.com> Co-authored-by: Adi Seredinschi <a@seredinschi.net>
This commit is contained in:
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
### IMPROVEMENTS
|
### IMPROVEMENTS
|
||||||
|
|
||||||
|
- `[rpc]` \#9724 Remove useless whitespace in RPC output (@adizere,
|
||||||
|
@thanethomson)
|
||||||
|
|
||||||
### BUG FIXES
|
### BUG FIXES
|
||||||
|
|
||||||
- `[rpc]` \#9692 Remove `Cache-Control` header response from `/check_tx`
|
- `[rpc]` \#9692 Remove `Cache-Control` header response from `/check_tx`
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
This guide provides instructions for upgrading to specific versions of
|
This guide provides instructions for upgrading to specific versions of
|
||||||
Tendermint Core.
|
Tendermint Core.
|
||||||
|
|
||||||
|
## v0.34.24
|
||||||
|
|
||||||
|
Note that in [\#9724](https://github.com/tendermint/tendermint/pull/9724) we
|
||||||
|
un-prettified the JSON output (i.e. removed all indentation) of the HTTP and
|
||||||
|
WebSocket RPC for performance and subscription stability reasons. We recommend
|
||||||
|
using a tool such as [jq](https://github.com/stedolan/jq) to obtain prettified
|
||||||
|
output if you rely on that prettified output in some way.
|
||||||
|
|
||||||
## v0.34.20
|
## v0.34.20
|
||||||
|
|
||||||
### Feature: Priority Mempool
|
### Feature: Priority Mempool
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func WriteRPCResponseHTTPError(
|
|||||||
panic("tried to write http error response without RPC error")
|
panic("tried to write http error response without RPC error")
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonBytes, err := json.MarshalIndent(res, "", " ")
|
jsonBytes, err := json.Marshal(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("json marshal: %w", err)
|
return fmt.Errorf("json marshal: %w", err)
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ func writeRPCResponseHTTP(w http.ResponseWriter, headers []httpHeader, res ...ty
|
|||||||
v = res
|
v = res
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonBytes, err := json.MarshalIndent(v, "", " ")
|
jsonBytes, err := json.Marshal(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("json marshal: %w", err)
|
return fmt.Errorf("json marshal: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,13 +121,7 @@ func TestWriteRPCResponseHTTP(t *testing.T) {
|
|||||||
assert.Equal(t, 200, resp.StatusCode)
|
assert.Equal(t, 200, resp.StatusCode)
|
||||||
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
|
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
|
||||||
assert.Equal(t, "public, max-age=86400", resp.Header.Get("Cache-control"))
|
assert.Equal(t, "public, max-age=86400", resp.Header.Get("Cache-control"))
|
||||||
assert.Equal(t, `{
|
assert.Equal(t, `{"jsonrpc":"2.0","id":-1,"result":{"value":"hello"}}`, string(body))
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": -1,
|
|
||||||
"result": {
|
|
||||||
"value": "hello"
|
|
||||||
}
|
|
||||||
}`, string(body))
|
|
||||||
|
|
||||||
// multiple arguments
|
// multiple arguments
|
||||||
w = httptest.NewRecorder()
|
w = httptest.NewRecorder()
|
||||||
@@ -142,22 +136,7 @@ func TestWriteRPCResponseHTTP(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, 200, resp.StatusCode)
|
assert.Equal(t, 200, resp.StatusCode)
|
||||||
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
|
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
|
||||||
assert.Equal(t, `[
|
assert.Equal(t, `[{"jsonrpc":"2.0","id":-1,"result":{"value":"hello"}},{"jsonrpc":"2.0","id":-1,"result":{"value":"world"}}]`, string(body))
|
||||||
{
|
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": -1,
|
|
||||||
"result": {
|
|
||||||
"value": "hello"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": -1,
|
|
||||||
"result": {
|
|
||||||
"value": "world"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]`, string(body))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWriteRPCResponseHTTPError(t *testing.T) {
|
func TestWriteRPCResponseHTTPError(t *testing.T) {
|
||||||
@@ -173,13 +152,5 @@ func TestWriteRPCResponseHTTPError(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, http.StatusInternalServerError, resp.StatusCode)
|
assert.Equal(t, http.StatusInternalServerError, resp.StatusCode)
|
||||||
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
|
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
|
||||||
assert.Equal(t, `{
|
assert.Equal(t, `{"jsonrpc":"2.0","id":-1,"error":{"code":-32603,"message":"Internal error","data":"foo"}}`, string(body))
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"id": -1,
|
|
||||||
"error": {
|
|
||||||
"code": -32603,
|
|
||||||
"message": "Internal error",
|
|
||||||
"data": "foo"
|
|
||||||
}
|
|
||||||
}`, string(body))
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -431,7 +431,10 @@ func (wsc *wsConnection) writeRoutine() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case msg := <-wsc.writeChan:
|
case msg := <-wsc.writeChan:
|
||||||
jsonBytes, err := json.MarshalIndent(msg, "", " ")
|
// Use json.MarshalIndent instead of Marshal for pretty output.
|
||||||
|
// Pretty output not necessary, since most consumers of WS events are
|
||||||
|
// automated processes, not humans.
|
||||||
|
jsonBytes, err := json.Marshal(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wsc.Logger.Error("Failed to marshal RPCResponse to JSON", "err", err)
|
wsc.Logger.Error("Failed to marshal RPCResponse to JSON", "err", err)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user