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.

35 lines
1.1 KiB

  1. package core
  2. import (
  3. "github.com/tendermint/go-wire"
  4. cm "github.com/tendermint/tendermint/consensus"
  5. ctypes "github.com/tendermint/tendermint/rpc/core/types"
  6. "github.com/tendermint/tendermint/types"
  7. )
  8. func Validators() (*ctypes.ResultValidators, error) {
  9. var blockHeight int
  10. var validators []*types.Validator
  11. state := consensusState.GetState()
  12. blockHeight = state.LastBlockHeight
  13. state.Validators.Iterate(func(index int, val *types.Validator) bool {
  14. validators = append(validators, val)
  15. return false
  16. })
  17. return &ctypes.ResultValidators{blockHeight, validators}, nil
  18. }
  19. func DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
  20. roundState := consensusState.GetRoundState()
  21. peerRoundStates := []string{}
  22. for _, peer := range p2pSwitch.Peers().List() {
  23. // TODO: clean this up?
  24. peerState := peer.Data.Get(types.PeerStateKey).(*cm.PeerState)
  25. peerRoundState := peerState.GetRoundState()
  26. peerRoundStateStr := peer.Key + ":" + string(wire.JSONBytes(peerRoundState))
  27. peerRoundStates = append(peerRoundStates, peerRoundStateStr)
  28. }
  29. return &ctypes.ResultDumpConsensusState{roundState.String(), peerRoundStates}, nil
  30. }