Include peer round states in the dump_consensus_state RPC call.

This commit is contained in:
Jae Kwon
2015-04-25 11:49:26 -07:00
parent 5557923245
commit 9a8652e001
6 changed files with 27 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package core
import (
"github.com/tendermint/tendermint/binary"
cm "github.com/tendermint/tendermint/consensus"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
sm "github.com/tendermint/tendermint/state"
)
@ -26,6 +27,14 @@ func ListValidators() (*ctypes.ResponseListValidators, error) {
}
func DumpConsensusState() (*ctypes.ResponseDumpConsensusState, error) {
jsonBytes := binary.JSONBytes(consensusState.GetRoundState())
return &ctypes.ResponseDumpConsensusState{string(jsonBytes)}, nil
roundState := consensusState.GetRoundState()
peerRoundStates := []string{}
for _, peer := range p2pSwitch.Peers().List() {
// TODO: clean this up?
peerState := peer.Data.Get(cm.PeerStateKey).(*cm.PeerState)
peerRoundState := peerState.GetRoundState()
peerRoundStateStr := peer.Key + ":" + string(binary.JSONBytes(peerRoundState))
peerRoundStates = append(peerRoundStates, peerRoundStateStr)
}
return &ctypes.ResponseDumpConsensusState{roundState.String(), peerRoundStates}, nil
}