Skip to content

Commit

Permalink
Merge pull request #1644 from irisnet/vincent/tx-search
Browse files Browse the repository at this point in the history
R4R: Fix tx search by tx.height
  • Loading branch information
zhangyelong authored Jun 21, 2019
2 parents 4f0242e + 2ee24e6 commit 60cf3c6
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions client/tendermint/tx/searchtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package tx
import (
"errors"
"fmt"
"net/http"
"net/url"
"strings"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/irisnet/irishub/client"
"github.com/irisnet/irishub/client/context"
"github.com/irisnet/irishub/client/utils"
"github.com/irisnet/irishub/codec"
sdk "github.com/irisnet/irishub/types"
"github.com/spf13/cobra"
"github.com/spf13/viper"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"net/http"
"net/url"
"github.com/tendermint/tendermint/types"
)

const (
Expand Down Expand Up @@ -60,7 +60,11 @@ $ iriscli tendermint txs --tags '<tag1>:<value1>&<tag2>:<value2>'
return fmt.Errorf("%s should only contain one <key>:<value> pair", tagsStr)
}
keyValue := strings.Split(tag, ":")
tag = fmt.Sprintf("%s='%s'", keyValue[0], keyValue[1])
if keyValue[0] == types.TxHeightKey {
tag = fmt.Sprintf("%s=%s", keyValue[0], keyValue[1])
} else {
tag = fmt.Sprintf("%s='%s'", keyValue[0], keyValue[1])
}
tmTags = append(tmTags, tag)
}

Expand Down Expand Up @@ -168,9 +172,11 @@ func SearchTxRequestHandlerFn(cliCtx context.CLIContext, cdc *codec.Codec) http.
utils.WriteErrorResponse(w, http.StatusBadRequest, sdk.AppendMsgToErr("could not decode query value", err.Error()))
return
}

tag := fmt.Sprintf("%s='%s'", key, value)
tags = append(tags, tag)
if key == types.TxHeightKey {
tags = append(tags, fmt.Sprintf("%s=%s", key, value))
} else {
tags = append(tags, fmt.Sprintf("%s='%s'", key, value))
}
}
pageString := r.FormValue("search_request_page")
sizeString := r.FormValue("search_request_size")
Expand Down

0 comments on commit 60cf3c6

Please sign in to comment.