mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 12:11:58 +00:00
Add back sample output in rpc/core/consensus.go; Tweak DumpConsensusState output for peers
This commit is contained in:
@@ -20,7 +20,7 @@ import (
|
||||
// state, err := client.Validators()
|
||||
// ```
|
||||
//
|
||||
// > The above command returns JSON structured like this:
|
||||
// The above command returns JSON structured like this:
|
||||
//
|
||||
// ```json
|
||||
// {
|
||||
@@ -59,23 +59,155 @@ func Validators(heightPtr *int64) (*ctypes.ResultValidators, error) {
|
||||
|
||||
// DumpConsensusState dumps consensus state.
|
||||
// UNSTABLE
|
||||
//
|
||||
// ```shell
|
||||
// curl 'localhost:46657/dump_consensus_state'
|
||||
// ```
|
||||
//
|
||||
// ```go
|
||||
// client := client.NewHTTP("tcp://0.0.0.0:46657", "/websocket")
|
||||
// state, err := client.DumpConsensusState()
|
||||
// ```
|
||||
//
|
||||
// The above command returns JSON structured like this:
|
||||
//
|
||||
// ```json
|
||||
// {
|
||||
// "jsonrpc": "2.0",
|
||||
// "id": "",
|
||||
// "result": {
|
||||
// "round_state": {
|
||||
// "height": 7185,
|
||||
// "round": 0,
|
||||
// "step": 1,
|
||||
// "start_time": "2018-05-12T13:57:28.440293621-07:00",
|
||||
// "commit_time": "2018-05-12T13:57:27.440293621-07:00",
|
||||
// "validators": {
|
||||
// "validators": [
|
||||
// {
|
||||
// "address": "B5B3D40BE53982AD294EF99FF5A34C0C3E5A3244",
|
||||
// "pub_key": {
|
||||
// "type": "AC26791624DE60",
|
||||
// "value": "SBctdhRBcXtBgdI/8a/alTsUhGXqGs9k5ylV1u5iKHg="
|
||||
// },
|
||||
// "voting_power": 10,
|
||||
// "accum": 0
|
||||
// }
|
||||
// ],
|
||||
// "proposer": {
|
||||
// "address": "B5B3D40BE53982AD294EF99FF5A34C0C3E5A3244",
|
||||
// "pub_key": {
|
||||
// "type": "AC26791624DE60",
|
||||
// "value": "SBctdhRBcXtBgdI/8a/alTsUhGXqGs9k5ylV1u5iKHg="
|
||||
// },
|
||||
// "voting_power": 10,
|
||||
// "accum": 0
|
||||
// }
|
||||
// },
|
||||
// "proposal": null,
|
||||
// "proposal_block": null,
|
||||
// "proposal_block_parts": null,
|
||||
// "locked_round": 0,
|
||||
// "locked_block": null,
|
||||
// "locked_block_parts": null,
|
||||
// "valid_round": 0,
|
||||
// "valid_block": null,
|
||||
// "valid_block_parts": null,
|
||||
// "votes": [
|
||||
// {
|
||||
// "round": 0,
|
||||
// "prevotes": "_",
|
||||
// "precommits": "_"
|
||||
// }
|
||||
// ],
|
||||
// "commit_round": -1,
|
||||
// "last_commit": {
|
||||
// "votes": [
|
||||
// "Vote{0:B5B3D40BE539 7184/00/2(Precommit) 14F946FA7EF0 /702B1B1A602A.../ @ 2018-05-12T20:57:27.342Z}"
|
||||
// ],
|
||||
// "votes_bit_array": "x",
|
||||
// "peer_maj_23s": {}
|
||||
// },
|
||||
// "last_validators": {
|
||||
// "validators": [
|
||||
// {
|
||||
// "address": "B5B3D40BE53982AD294EF99FF5A34C0C3E5A3244",
|
||||
// "pub_key": {
|
||||
// "type": "AC26791624DE60",
|
||||
// "value": "SBctdhRBcXtBgdI/8a/alTsUhGXqGs9k5ylV1u5iKHg="
|
||||
// },
|
||||
// "voting_power": 10,
|
||||
// "accum": 0
|
||||
// }
|
||||
// ],
|
||||
// "proposer": {
|
||||
// "address": "B5B3D40BE53982AD294EF99FF5A34C0C3E5A3244",
|
||||
// "pub_key": {
|
||||
// "type": "AC26791624DE60",
|
||||
// "value": "SBctdhRBcXtBgdI/8a/alTsUhGXqGs9k5ylV1u5iKHg="
|
||||
// },
|
||||
// "voting_power": 10,
|
||||
// "accum": 0
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// "peers": [
|
||||
// {
|
||||
// "node_address": "30ad1854af22506383c3f0e57fb3c7f90984c5e8@172.16.63.221:46656",
|
||||
// "peer_state": {
|
||||
// "round_state": {
|
||||
// "height": 7185,
|
||||
// "round": 0,
|
||||
// "step": 1,
|
||||
// "start_time": "2018-05-12T13:57:27.438039872-07:00",
|
||||
// "proposal": false,
|
||||
// "proposal_block_parts_header": {
|
||||
// "total": 0,
|
||||
// "hash": ""
|
||||
// },
|
||||
// "proposal_block_parts": null,
|
||||
// "proposal_pol_round": -1,
|
||||
// "proposal_pol": "_",
|
||||
// "prevotes": "_",
|
||||
// "precommits": "_",
|
||||
// "last_commit_round": 0,
|
||||
// "last_commit": "x",
|
||||
// "catchup_commit_round": -1,
|
||||
// "catchup_commit": "_"
|
||||
// },
|
||||
// "stats": {
|
||||
// "last_vote_height": 7184,
|
||||
// "votes": 255,
|
||||
// "last_block_part_height": 7184,
|
||||
// "block_parts": 255
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
func DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
|
||||
// Get Peer consensus states.
|
||||
peers := p2pSwitch.Peers().List()
|
||||
peerRoundStates := make([]ctypes.PeerRoundStateInfo, len(peers))
|
||||
peerStates := make([]ctypes.PeerStateInfo, len(peers))
|
||||
for i, peer := range peers {
|
||||
peerState := peer.Get(types.PeerStateKey).(*cm.PeerState)
|
||||
peerRoundState, err := peerState.GetRoundStateJSON()
|
||||
peerStateJSON, err := peerState.ToJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
peerRoundStates[i] = ctypes.PeerRoundStateInfo{
|
||||
NodeAddress: p2p.IDAddressString(peer.ID(), peer.NodeInfo().ListenAddr),
|
||||
PeerRoundState: peerRoundState,
|
||||
peerStates[i] = ctypes.PeerStateInfo{
|
||||
// Peer basic info.
|
||||
NodeAddress: p2p.IDAddressString(peer.ID(), peer.NodeInfo().ListenAddr),
|
||||
// Peer consensus state.
|
||||
PeerState: peerStateJSON,
|
||||
}
|
||||
}
|
||||
// Get self round state.
|
||||
roundState, err := consensusState.GetRoundStateJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ctypes.ResultDumpConsensusState{roundState, peerRoundStates}, nil
|
||||
return &ctypes.ResultDumpConsensusState{roundState, peerStates}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user