Skip to content

Commit

Permalink
Merge PR #4550: Minor Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Jun 14, 2019
1 parent 95f3d32 commit d5fe9b7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions client/context/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func (ctx CLIContext) GetNode() (rpcclient.Client, error) {
}

// Query performs a query to a Tendermint node with the provided path.
// It returns the result and height of the query upon success
// or an error if the query fails.
func (ctx CLIContext) Query(path string, data cmn.HexBytes) ([]byte, int64, error) {
return ctx.query(path, data)
// It returns the result and height of the query upon success or an error if
// the query fails.
func (ctx CLIContext) Query(path string) ([]byte, int64, error) {
return ctx.query(path, nil)
}

// QueryWithData performs a query to a Tendermint node with the provided path
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ func CLIVersionRequestHandler(w http.ResponseWriter, r *http.Request) {
// connected node version REST handler endpoint
func NodeVersionRequestHandler(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
version, _, err := cliCtx.Query("/app/version", nil)
res, _, err := cliCtx.Query("/app/version")
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}

w.Header().Set("Content-Type", "application/json")
if _, err := w.Write(version); err != nil {
if _, err := w.Write(res); err != nil {
log.Printf("could not write response: %v", err)
}
}
Expand Down
6 changes: 2 additions & 4 deletions client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/tendermint/tendermint/libs/common"

"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/input"
Expand Down Expand Up @@ -127,7 +125,7 @@ func EnrichWithGas(txBldr authtypes.TxBuilder, cliCtx context.CLIContext, msgs [

// CalculateGas simulates the execution of a transaction and returns
// both the estimate obtained by the query and the adjusted amount.
func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, int64, error),
func CalculateGas(queryFunc func(string, []byte) ([]byte, int64, error),
cdc *codec.Codec, txBytes []byte, adjustment float64) (estimate, adjusted uint64, err error) {

// run a simulation (via /app/simulate query) to
Expand Down Expand Up @@ -275,7 +273,7 @@ func simulateMsgs(txBldr authtypes.TxBuilder, cliCtx context.CLIContext, msgs []
if err != nil {
return
}
estimated, adjusted, err = CalculateGas(cliCtx.Query, cliCtx.Codec, txBytes, txBldr.GasAdjustment())
estimated, adjusted, err = CalculateGas(cliCtx.QueryWithData, cliCtx.Codec, txBytes, txBldr.GasAdjustment())
return
}

Expand Down
5 changes: 2 additions & 3 deletions client/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/libs/common"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -36,8 +35,8 @@ func TestParseQueryResponse(t *testing.T) {

func TestCalculateGas(t *testing.T) {
cdc := makeCodec()
makeQueryFunc := func(gasUsed uint64, wantErr bool) func(string, common.HexBytes) ([]byte, int64, error) {
return func(string, common.HexBytes) ([]byte, int64, error) {
makeQueryFunc := func(gasUsed uint64, wantErr bool) func(string, []byte) ([]byte, int64, error) {
return func(string, []byte) ([]byte, int64, error) {
if wantErr {
return nil, 0, errors.New("")
}
Expand Down
4 changes: 2 additions & 2 deletions x/auth/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
)

// AccountWithHeight wraps the embedded Account
// with the height it was queried at
// AccountWithHeight wraps the embedded Account with the height it was queried
// at.
type AccountWithHeight struct {
types.Account
Height int64 `json:"height"`
Expand Down

0 comments on commit d5fe9b7

Please sign in to comment.