mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-28 04:01:40 +00:00
rpc: historical validators
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user