2015-03-26 21:30:42 -07:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2015-11-01 11:34:08 -08:00
|
|
|
"github.com/tendermint/go-wire"
|
2015-04-25 11:49:26 -07:00
|
|
|
cm "github.com/tendermint/tendermint/consensus"
|
2015-04-07 11:44:25 -07:00
|
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
2015-08-10 20:38:45 -07:00
|
|
|
"github.com/tendermint/tendermint/types"
|
2015-03-26 21:30:42 -07:00
|
|
|
)
|
|
|
|
|
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
|
2015-03-26 21:30:42 -07:00
|
|
|
}
|
2015-04-20 20:39:42 -07:00
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
func DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
|
2015-04-25 11:49:26 -07:00
|
|
|
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)
|
2015-04-25 11:49:26 -07:00
|
|
|
peerRoundState := peerState.GetRoundState()
|
2015-07-25 15:45:45 -07:00
|
|
|
peerRoundStateStr := peer.Key + ":" + string(wire.JSONBytes(peerRoundState))
|
2015-04-25 11:49:26 -07:00
|
|
|
peerRoundStates = append(peerRoundStates, peerRoundStateStr)
|
|
|
|
}
|
2015-08-10 20:38:45 -07:00
|
|
|
return &ctypes.ResultDumpConsensusState{roundState.String(), peerRoundStates}, nil
|
2015-04-20 20:39:42 -07:00
|
|
|
}
|