mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 05:25:35 +00:00
lite2/rpc: verify block results and validators (#4703)
Closes: #4695 Verify /block_results and /validators responses from an HTTP client using the light client. Added count and total to /validators response. Refs #3113
This commit is contained in:
@@ -10,9 +10,11 @@ import (
|
||||
)
|
||||
|
||||
// Validators gets the validator set at the given block height.
|
||||
// If no height is provided, it will fetch the current validator set.
|
||||
// Note the validators are sorted by their address - this is the canonical
|
||||
// order for the validators in the set as used in computing their Merkle root.
|
||||
//
|
||||
// If no height is provided, it will fetch the current validator set. Note the
|
||||
// validators are sorted by their address - this is the canonical order for the
|
||||
// validators in the set as used in computing their Merkle root.
|
||||
//
|
||||
// More: https://docs.tendermint.com/master/rpc/#/Info/validators
|
||||
func Validators(ctx *rpctypes.Context, heightPtr *int64, page, perPage int) (*ctypes.ResultValidators, error) {
|
||||
// The latest validator that we know is the
|
||||
@@ -41,7 +43,9 @@ func Validators(ctx *rpctypes.Context, heightPtr *int64, page, perPage int) (*ct
|
||||
|
||||
return &ctypes.ResultValidators{
|
||||
BlockHeight: height,
|
||||
Validators: v}, nil
|
||||
Validators: v,
|
||||
Count: len(v),
|
||||
Total: totalCount}, nil
|
||||
}
|
||||
|
||||
// DumpConsensusState dumps consensus state.
|
||||
|
||||
@@ -122,10 +122,14 @@ type Peer struct {
|
||||
RemoteIP string `json:"remote_ip"`
|
||||
}
|
||||
|
||||
// Validators for a height
|
||||
// Validators for a height.
|
||||
type ResultValidators struct {
|
||||
BlockHeight int64 `json:"block_height"`
|
||||
Validators []*types.Validator `json:"validators"`
|
||||
// Count of actual validators in this result
|
||||
Count int `json:"count"`
|
||||
// Total number of validators
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
// ConsensusParams for given height
|
||||
|
||||
Reference in New Issue
Block a user