mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 12:51:22 +00:00
Include peer round states in the dump_consensus_state RPC call.
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user