tendermint/rpc/core/consensus.go

27 lines
951 B
Go
Raw Normal View History

package core
import (
2015-11-01 11:34:08 -08:00
"github.com/tendermint/go-wire"
cm "github.com/tendermint/tendermint/consensus"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types"
)
2016-02-08 00:48:58 -08:00
func Validators() (*ctypes.ResultValidators, error) {
2016-10-14 18:36:42 -07:00
blockHeight, validators := consensusState.GetValidators()
2016-02-08 00:48:58 -08:00
return &ctypes.ResultValidators{blockHeight, validators}, nil
}
func DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
roundState := consensusState.GetRoundState()
peerRoundStates := []string{}
for _, peer := range p2pSwitch.Peers().List() {
// TODO: clean this up?
2015-09-25 09:55:59 -07:00
peerState := peer.Data.Get(types.PeerStateKey).(*cm.PeerState)
peerRoundState := peerState.GetRoundState()
2015-07-25 15:45:45 -07:00
peerRoundStateStr := peer.Key + ":" + string(wire.JSONBytes(peerRoundState))
peerRoundStates = append(peerRoundStates, peerRoundStateStr)
}
return &ctypes.ResultDumpConsensusState{roundState.String(), peerRoundStates}, nil
}