You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
775 B

  1. package core
  2. import (
  3. sm "github.com/tendermint/tendermint/state"
  4. )
  5. //-----------------------------------------------------------------------------
  6. func ListValidators() (*ResponseListValidators, error) {
  7. var blockHeight uint
  8. var bondedValidators []*sm.Validator
  9. var unbondingValidators []*sm.Validator
  10. state := consensusState.GetState()
  11. blockHeight = state.LastBlockHeight
  12. state.BondedValidators.Iterate(func(index uint, val *sm.Validator) bool {
  13. bondedValidators = append(bondedValidators, val)
  14. return false
  15. })
  16. state.UnbondingValidators.Iterate(func(index uint, val *sm.Validator) bool {
  17. unbondingValidators = append(unbondingValidators, val)
  18. return false
  19. })
  20. return &ResponseListValidators{blockHeight, bondedValidators, unbondingValidators}, nil
  21. }