Merge PR #5527: Bump Tendermint Version to v0.33.0
* Bump Tendermint version to v0.33.0 * Deprecate old cmn package with new packages * Update update DB APIs * More DB updates * Bump IAVL to v0.13.0 * Handle error returned by iavl.NewMutableTree * Fix some IAVL stuffs * Update IAVL * More updates * Passing tests * Fix unit tests Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com>
This commit is contained in:
committed by
Jack Zampolin
co-authored by
Jack Zampolin
parent
c92a7389ff
commit
c1991e31bd
+2
-4
@@ -53,13 +53,11 @@ func getBlock(cliCtx context.CLIContext, height *int64) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = tmliteProxy.ValidateBlockMeta(res.BlockMeta, check)
|
||||
if err != nil {
|
||||
if err := tmliteProxy.ValidateHeader(&res.Block.Header, check); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = tmliteProxy.ValidateBlock(res.Block, check)
|
||||
if err != nil {
|
||||
if err = tmliteProxy.ValidateBlock(res.Block, check); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func ValidatorCommand(cdc *codec.Codec) *cobra.Command {
|
||||
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
|
||||
result, err := GetValidators(cliCtx, height)
|
||||
result, err := GetValidators(cliCtx, height, viper.GetInt(flags.FlagPage), viper.GetInt(flags.FlagLimit))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -60,6 +60,9 @@ func ValidatorCommand(cdc *codec.Codec) *cobra.Command {
|
||||
viper.BindPFlag(flags.FlagTrustNode, cmd.Flags().Lookup(flags.FlagTrustNode))
|
||||
cmd.Flags().Bool(flags.FlagIndentResponse, false, "indent JSON response")
|
||||
viper.BindPFlag(flags.FlagIndentResponse, cmd.Flags().Lookup(flags.FlagIndentResponse))
|
||||
cmd.Flags().Int(flags.FlagPage, 0, "Query a specific page of paginated results")
|
||||
viper.BindPFlag(flags.FlagPage, cmd.Flags().Lookup(flags.FlagPage))
|
||||
cmd.Flags().Int(flags.FlagLimit, 100, "Query number of results returned per page")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -114,14 +117,14 @@ func bech32ValidatorOutput(validator *tmtypes.Validator) (ValidatorOutput, error
|
||||
}
|
||||
|
||||
// GetValidators from client
|
||||
func GetValidators(cliCtx context.CLIContext, height *int64) (ResultValidatorsOutput, error) {
|
||||
func GetValidators(cliCtx context.CLIContext, height *int64, page, limit int) (ResultValidatorsOutput, error) {
|
||||
// get the node
|
||||
node, err := cliCtx.GetNode()
|
||||
if err != nil {
|
||||
return ResultValidatorsOutput{}, err
|
||||
}
|
||||
|
||||
validatorsRes, err := node.Validators(height)
|
||||
validatorsRes, err := node.Validators(height, page, limit)
|
||||
if err != nil {
|
||||
return ResultValidatorsOutput{}, err
|
||||
}
|
||||
@@ -159,6 +162,18 @@ func ValidatorSetRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
|
||||
page, err := strconv.ParseInt(vars["page"], 10, 64)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse page")
|
||||
return
|
||||
}
|
||||
|
||||
limit, err := strconv.ParseInt(vars["limit"], 10, 64)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse limit")
|
||||
return
|
||||
}
|
||||
|
||||
height, err := strconv.ParseInt(vars["height"], 10, 64)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse block height; assumed format is '/validatorsets/{height}'")
|
||||
@@ -175,7 +190,7 @@ func ValidatorSetRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
output, err := GetValidators(cliCtx, &height)
|
||||
output, err := GetValidators(cliCtx, &height, int(page), int(limit))
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@@ -187,7 +202,21 @@ func ValidatorSetRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
// Latest Validator Set REST handler
|
||||
func LatestValidatorSetRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
output, err := GetValidators(cliCtx, nil)
|
||||
vars := mux.Vars(r)
|
||||
|
||||
page, err := strconv.ParseInt(vars["page"], 10, 64)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse page")
|
||||
return
|
||||
}
|
||||
|
||||
limit, err := strconv.ParseInt(vars["limit"], 10, 64)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse limit")
|
||||
return
|
||||
}
|
||||
|
||||
output, err := GetValidators(cliCtx, nil, int(page), int(limit))
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user