Browse Source

rpc: added proposer in consensus_state (#4250)

* added proposer in consensus_state

* added proposer in consensus_state

* proposer changes

* added proposer in consensus_state

* proposer added
pull/4258/head
Prince Sinha 5 years ago
committed by Marko
parent
commit
f0777277ad
3 changed files with 27 additions and 8 deletions
  1. +2
    -2
      CHANGELOG_PENDING.md
  2. +15
    -6
      consensus/types/round_state.go
  3. +10
    -0
      rpc/swagger/swagger.yaml

+ 2
- 2
CHANGELOG_PENDING.md View File

@ -122,8 +122,8 @@ program](https://hackerone.com/tendermint).
- [cli] [\#4065](https://github.com/tendermint/tendermint/issues/4065) Add `--consensus.create_empty_blocks_interval` flag (@jgimeno)
- [docs] [\#4065](https://github.com/tendermint/tendermint/issues/4065) Document `--consensus.create_empty_blocks_interval` flag (@jgimeno)
- [crypto] [\#4190](https://github.com/tendermint/tendermint/pull/4190) Added SR25519 signature scheme
- [abci] \#4177 kvstore: Return `LastBlockHeight` and `LastBlockAppHash` in `Info` (@princesinha19)
- [abci] [\#4177] kvstore: Return `LastBlockHeight` and `LastBlockAppHash` in `Info` (@princesinha19)
- [rpc] [\#2741](https://github.com/tendermint/tendermint/issues/2741) Add `proposer` to `/consensus_state` response (@princesinha19)
### BUG FIXES:


+ 15
- 6
consensus/types/round_state.go View File

@ -95,12 +95,13 @@ type RoundState struct {
// Compressed version of the RoundState for use in RPC
type RoundStateSimple struct {
HeightRoundStep string `json:"height/round/step"`
StartTime time.Time `json:"start_time"`
ProposalBlockHash bytes.HexBytes `json:"proposal_block_hash"`
LockedBlockHash bytes.HexBytes `json:"locked_block_hash"`
ValidBlockHash bytes.HexBytes `json:"valid_block_hash"`
Votes json.RawMessage `json:"height_vote_set"`
HeightRoundStep string `json:"height/round/step"`
StartTime time.Time `json:"start_time"`
ProposalBlockHash bytes.HexBytes `json:"proposal_block_hash"`
LockedBlockHash bytes.HexBytes `json:"locked_block_hash"`
ValidBlockHash bytes.HexBytes `json:"valid_block_hash"`
Votes json.RawMessage `json:"height_vote_set"`
Proposer types.ValidatorInfo `json:"proposer"`
}
// Compress the RoundState to RoundStateSimple
@ -109,6 +110,10 @@ func (rs *RoundState) RoundStateSimple() RoundStateSimple {
if err != nil {
panic(err)
}
addr := rs.Validators.GetProposer().Address
idx, _ := rs.Validators.GetByAddress(addr)
return RoundStateSimple{
HeightRoundStep: fmt.Sprintf("%d/%d/%d", rs.Height, rs.Round, rs.Step),
StartTime: rs.StartTime,
@ -116,6 +121,10 @@ func (rs *RoundState) RoundStateSimple() RoundStateSimple {
LockedBlockHash: rs.LockedBlock.Hash(),
ValidBlockHash: rs.ValidBlock.Hash(),
Votes: votesJSON,
Proposer: types.ValidatorInfo{
Address: addr,
Index: idx,
},
}
}


+ 10
- 0
rpc/swagger/swagger.yaml View File

@ -2351,6 +2351,7 @@ components:
- "locked_block_hash"
- "valid_block_hash"
- "height_vote_set"
- "proposer"
properties:
height/round/step:
type: "string"
@ -2395,6 +2396,15 @@ components:
precommits_bit_array:
type: "string"
example: "BA{100:xxxxxx_xxxxx_xxxx_x_xxx_xx_xx_xx__x_x_x__xxxxxxxxxxxxxx_xxxx_xx_xxxxxx_xxxxxxxx_xxxx_xxx_x_xxxx__xxx} 118726247/170151262 = 0.70"
proposer:
type: "object"
properties:
address:
type: "string"
example: "D540AB022088612AC74B287D076DBFBC4A377A2E"
index:
type: "string"
example: "0"
type: "object"
type: "object"
ConsensusParamsResponse:


Loading…
Cancel
Save