rpc: historical validators

This commit is contained in:
Ethan Buchman
2017-08-21 18:11:16 -04:00
parent 78446fd99c
commit e2e8746044
9 changed files with 31 additions and 15 deletions

View File

@ -7,7 +7,8 @@ import (
"github.com/tendermint/tendermint/types"
)
// Get current validators set along with a block height.
// Get the validator set at a give block height.
// If no height is provided, it will fetch the current validator set.
//
// ```shell
// curl 'localhost:46657/validators'
@ -41,9 +42,17 @@ import (
// "jsonrpc": "2.0"
// }
// ```
func Validators() (*ctypes.ResultValidators, error) {
blockHeight, validators := consensusState.GetValidators()
return &ctypes.ResultValidators{blockHeight, validators}, nil
func Validators(height *int) (*ctypes.ResultValidators, error) {
if height == nil {
blockHeight, validators := consensusState.GetValidators()
return &ctypes.ResultValidators{blockHeight, validators}, nil
}
state := consensusState.GetState()
validators, err := state.LoadValidators(*height)
if err != nil {
return nil, err
}
return &ctypes.ResultValidators{*height, validators.Validators}, nil
}
// Dump consensus state.