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.

30 lines
826 B

  1. package rpc
  2. import (
  3. "net/http"
  4. sm "github.com/tendermint/tendermint/state"
  5. )
  6. func ListValidatorsHandler(w http.ResponseWriter, r *http.Request) {
  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. WriteAPIResponse(w, API_OK, struct {
  21. BlockHeight uint
  22. BondedValidators []*sm.Validator
  23. UnbondingValidators []*sm.Validator
  24. }{blockHeight, bondedValidators, unbondingValidators})
  25. }