From c1ca749afabe7cbe4fd330fbb8dd34ff5b04ac9f Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 23 Feb 2021 14:56:16 +0400 Subject: [PATCH] rpc: change default sorting to desc for `/tx_search` results (#6168) Closes #6155 --- CHANGELOG_PENDING.md | 3 ++- rpc/core/tx.go | 4 ++-- rpc/openapi/openapi.yaml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index ba20e0475..c39b78551 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -14,6 +14,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi - [cli] \#5772 `gen_node_key` prints JSON-encoded `NodeKey` rather than ID and does not save it to `node_key.json` (@melekes) - [cli] \#5777 use hyphen-case instead of snake_case for all cli commands and config parameters (@cmwaters) - [rpc] \#6019 standardise RPC errors and return the correct status code (@bipulprasad & @cmwaters) + - [rpc] \#6168 Change default sorting to desc for `/tx_search` results (@melekes) - Apps - [ABCI] \#5447 Remove `SetOption` method from `ABCI.Client` interface @@ -29,7 +30,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi - [proto/p2p] Renamed `DefaultNodeInfo` and `DefaultNodeInfoOther` to `NodeInfo` and `NodeInfoOther` (@erikgrinaker) - [proto/p2p] Rename `NodeInfo.default_node_id` to `node_id` (@erikgrinaker) - [libs/os] Kill() and {Must,}{Read,Write}File() functions have been removed. (@alessio) - - [store] \#5848 Remove block store state in favor of using the db iterators directly (@cmwaters) + - [store] \#5848 Remove block store state in favor of using the db iterators directly (@cmwaters) - [state] \#5864 Use an iterator when pruning state (@cmwaters) - [types] \#6023 Remove `tm2pb.Header`, `tm2pb.BlockID`, `tm2pb.PartSetHeader` and `tm2pb.NewValidatorUpdate`. - Each of the above types has a `ToProto` and `FromProto` method or function which replaced this logic. diff --git a/rpc/core/tx.go b/rpc/core/tx.go index 415176552..98721db8e 100644 --- a/rpc/core/tx.go +++ b/rpc/core/tx.go @@ -73,14 +73,14 @@ func TxSearch(ctx *rpctypes.Context, query string, prove bool, pagePtr, perPageP // sort results (must be done before pagination) switch orderBy { - case "desc": + case "desc", "": sort.Slice(results, func(i, j int) bool { if results[i].Height == results[j].Height { return results[i].Index > results[j].Index } return results[i].Height > results[j].Height }) - case "asc", "": + case "asc": sort.Slice(results, func(i, j int) bool { if results[i].Height == results[j].Height { return results[i].Index < results[j].Index diff --git a/rpc/openapi/openapi.yaml b/rpc/openapi/openapi.yaml index 7473b8620..ed7771ba1 100644 --- a/rpc/openapi/openapi.yaml +++ b/rpc/openapi/openapi.yaml @@ -1004,7 +1004,7 @@ paths: required: false schema: type: string - default: "asc" + default: "desc" example: "asc" tags: - Info