rpc: Block and Commit take pointers; return latest on nil

This commit is contained in:
Ethan Buchman
2017-08-22 17:42:23 -04:00
parent e2e8746044
commit f0f1ebe013
7 changed files with 41 additions and 23 deletions

View File

@ -42,17 +42,19 @@ import (
// "jsonrpc": "2.0"
// }
// ```
func Validators(height *int) (*ctypes.ResultValidators, error) {
if height == nil {
func Validators(heightPtr *int) (*ctypes.ResultValidators, error) {
if heightPtr == nil {
blockHeight, validators := consensusState.GetValidators()
return &ctypes.ResultValidators{blockHeight, validators}, nil
}
height := *heightPtr
state := consensusState.GetState()
validators, err := state.LoadValidators(*height)
validators, err := state.LoadValidators(height)
if err != nil {
return nil, err
}
return &ctypes.ResultValidators{*height, validators.Validators}, nil
return &ctypes.ResultValidators{height, validators.Validators}, nil
}
// Dump consensus state.