Merge PR #5648: Add min-height and max-height filters to TxSearch
This commit is contained in:
@@ -22,6 +22,8 @@ import (
|
||||
const (
|
||||
DefaultPage = 1
|
||||
DefaultLimit = 30 // should be consistent with tendermint/tendermint/rpc/core/pipe.go:19
|
||||
TxMinHeightKey = "tx.minheight" // Inclusive minimum height filter
|
||||
TxMaxHeightKey = "tx.maxheight" // Inclusive maximum height filter
|
||||
)
|
||||
|
||||
// ResponseWithHeight defines a response object type that wraps an original
|
||||
@@ -337,6 +339,10 @@ func ParseHTTPArgsWithLimit(r *http.Request, defaultLimit int) (tags []string, p
|
||||
var tag string
|
||||
if key == types.TxHeightKey {
|
||||
tag = fmt.Sprintf("%s=%s", key, value)
|
||||
} else if key == TxMinHeightKey {
|
||||
tag = fmt.Sprintf("%s>=%s", types.TxHeightKey, value)
|
||||
} else if key == TxMaxHeightKey {
|
||||
tag = fmt.Sprintf("%s<=%s", types.TxHeightKey, value)
|
||||
} else {
|
||||
tag = fmt.Sprintf("%s='%s'", key, value)
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ func TestParseHTTPArgs(t *testing.T) {
|
||||
reqE2 := mustNewRequest(t, "", "/?limit=-1", nil)
|
||||
req4 := mustNewRequest(t, "", "/?foo=faa", nil)
|
||||
|
||||
reqTxH := mustNewRequest(t, "", "/?tx.minheight=12&tx.maxheight=14", nil)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
req *http.Request
|
||||
@@ -89,6 +91,7 @@ func TestParseHTTPArgs(t *testing.T) {
|
||||
{"error limit 0", reqE2, httptest.NewRecorder(), []string{}, DefaultPage, DefaultLimit, true},
|
||||
|
||||
{"tags", req4, httptest.NewRecorder(), []string{"foo='faa'"}, DefaultPage, DefaultLimit, false},
|
||||
{"tags", reqTxH, httptest.NewRecorder(), []string{"tx.height>=12", "tx.height<=14"}, DefaultPage, DefaultLimit, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
Reference in New Issue
Block a user