mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 21:01:21 +00:00
fixes from review
This commit is contained in:
@ -126,6 +126,15 @@ func (c *HTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *HTTP) ConsensusState() (*ctypes.ResultConsensusState, error) {
|
||||
result := new(ctypes.ResultConsensusState)
|
||||
_, err := c.rpc.Call("consensus_state", map[string]interface{}{}, result)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "ConsensusState")
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *HTTP) Health() (*ctypes.ResultHealth, error) {
|
||||
result := new(ctypes.ResultHealth)
|
||||
_, err := c.rpc.Call("health", map[string]interface{}{}, result)
|
||||
|
@ -84,6 +84,7 @@ type Client interface {
|
||||
type NetworkClient interface {
|
||||
NetInfo() (*ctypes.ResultNetInfo, error)
|
||||
DumpConsensusState() (*ctypes.ResultDumpConsensusState, error)
|
||||
ConsensusState() (*ctypes.ResultConsensusState, error)
|
||||
Health() (*ctypes.ResultHealth, error)
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,10 @@ func (Local) DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
|
||||
return core.DumpConsensusState()
|
||||
}
|
||||
|
||||
func (Local) ConsensusState() (*ctypes.ResultConsensusState, error) {
|
||||
return core.ConsensusState()
|
||||
}
|
||||
|
||||
func (Local) Health() (*ctypes.ResultHealth, error) {
|
||||
return core.Health()
|
||||
}
|
||||
|
@ -78,6 +78,17 @@ func TestDumpConsensusState(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsensusState(t *testing.T) {
|
||||
for i, c := range GetClients() {
|
||||
// FIXME: fix server so it doesn't panic on invalid input
|
||||
nc, ok := c.(client.NetworkClient)
|
||||
require.True(t, ok, "%d", i)
|
||||
cons, err := nc.ConsensusState()
|
||||
require.Nil(t, err, "%d: %+v", i, err)
|
||||
assert.NotEmpty(t, cons.RoundState)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealth(t *testing.T) {
|
||||
for i, c := range GetClients() {
|
||||
nc, ok := c.(client.NetworkClient)
|
||||
|
@ -212,7 +212,48 @@ func DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
|
||||
return &ctypes.ResultDumpConsensusState{roundState, peerStates}, nil
|
||||
}
|
||||
|
||||
// ConsensusState returns a concise summary of the consensus state.
|
||||
// UNSTABLE
|
||||
//
|
||||
// ```shell
|
||||
// curl 'localhost:46657/consensus_state'
|
||||
// ```
|
||||
//
|
||||
// ```go
|
||||
// client := client.NewHTTP("tcp://0.0.0.0:46657", "/websocket")
|
||||
// state, err := client.ConsensusState()
|
||||
// ```
|
||||
//
|
||||
// The above command returns JSON structured like this:
|
||||
//
|
||||
// ```json
|
||||
//{
|
||||
// "jsonrpc": "2.0",
|
||||
// "id": "",
|
||||
// "result": {
|
||||
// "round_state": {
|
||||
// "height/round/step": "9336/0/1",
|
||||
// "start_time": "2018-05-14T10:25:45.72595357-04:00",
|
||||
// "proposal_block_hash": "",
|
||||
// "locked_block_hash": "",
|
||||
// "valid_block_hash": "",
|
||||
// "height_vote_set": [
|
||||
// {
|
||||
// "round": 0,
|
||||
// "prevotes": [
|
||||
// "nil-Vote"
|
||||
// ],
|
||||
// "prevotes_bit_array": "BA{1:_} 0/10 = 0.00",
|
||||
// "precommits": [
|
||||
// "nil-Vote"
|
||||
// ],
|
||||
// "precommits_bit_array": "BA{1:_} 0/10 = 0.00"
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//```
|
||||
func ConsensusState() (*ctypes.ResultConsensusState, error) {
|
||||
// Get self round state.
|
||||
bz, err := consensusState.GetRoundStateSimpleJSON()
|
||||
|
Reference in New Issue
Block a user