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.

31 lines
1014 B

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