Merge PR #4550: Minor Cleanup
This commit is contained in:
parent
95f3d32250
commit
d5fe9b7eef
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
@ -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("")
|
||||
}
|
||||
|
|
|
@ -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"`
|
||||
|
|
Loading…
Reference in New Issue