Browse Source

rpc: lower_case peer_round_states, use a list, add the node_address

pull/1514/head
Ethan Buchman 7 years ago
parent
commit
f33da8817a
4 changed files with 31 additions and 23 deletions
  1. +1
    -0
      consensus/state.go
  2. +15
    -15
      consensus/types/peer_round_state.go
  3. +8
    -6
      rpc/core/consensus.go
  4. +7
    -2
      rpc/core/types/responses.go

+ 1
- 0
consensus/state.go View File

@ -990,6 +990,7 @@ func (cs *ConsensusState) enterPrecommit(height int64, round int) {
cs.newStep()
}()
// check for a polka
blockID, ok := cs.Votes.Prevotes(round).TwoThirdsMajority()
// If we don't have a polka, we must precommit nil


+ 15
- 15
consensus/types/peer_round_state.go View File

@ -13,21 +13,21 @@ import (
// PeerRoundState contains the known state of a peer.
// NOTE: Read-only when returned by PeerState.GetRoundState().
type PeerRoundState struct {
Height int64 // Height peer is at
Round int // Round peer is at, -1 if unknown.
Step RoundStepType // Step peer is at
StartTime time.Time // Estimated start of round 0 at this height
Proposal bool // True if peer has proposal for this round
ProposalBlockPartsHeader types.PartSetHeader //
ProposalBlockParts *cmn.BitArray //
ProposalPOLRound int // Proposal's POL round. -1 if none.
ProposalPOL *cmn.BitArray // nil until ProposalPOLMessage received.
Prevotes *cmn.BitArray // All votes peer has for this round
Precommits *cmn.BitArray // All precommits peer has for this round
LastCommitRound int // Round of commit for last height. -1 if none.
LastCommit *cmn.BitArray // All commit precommits of commit for last height.
CatchupCommitRound int // Round that we have commit for. Not necessarily unique. -1 if none.
CatchupCommit *cmn.BitArray // All commit precommits peer has for this height & CatchupCommitRound
Height int64 `json:"height"` // Height peer is at
Round int `json:"round"` // Round peer is at, -1 if unknown.
Step RoundStepType `json:"step"` // Step peer is at
StartTime time.Time `json:"start_time"` // Estimated start of round 0 at this height
Proposal bool `json:"proposal"` // True if peer has proposal for this round
ProposalBlockPartsHeader types.PartSetHeader `json:"proposal_block_parts_header"` //
ProposalBlockParts *cmn.BitArray `json:"proposal_block_parts"` //
ProposalPOLRound int `json:"proposal_pol_round"` // Proposal's POL round. -1 if none.
ProposalPOL *cmn.BitArray `json:"proposal_pol"` // nil until ProposalPOLMessage received.
Prevotes *cmn.BitArray `json:"prevotes"` // All votes peer has for this round
Precommits *cmn.BitArray `json:"precommits"` // All precommits peer has for this round
LastCommitRound int `json:"last_commit_round"` // Round of commit for last height. -1 if none.
LastCommit *cmn.BitArray `json:"last_commit"` // All commit precommits of commit for last height.
CatchupCommitRound int `json:"catchup_commit_round"` // Round that we have commit for. Not necessarily unique. -1 if none.
CatchupCommit *cmn.BitArray `json:"catchup_commit"` // All commit precommits peer has for this height & CatchupCommitRound
}
// String returns a string representation of the PeerRoundState


+ 8
- 6
rpc/core/consensus.go View File

@ -1,10 +1,8 @@
package core
import (
"encoding/json"
cm "github.com/tendermint/tendermint/consensus"
p2p "github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/p2p"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
@ -84,14 +82,18 @@ func Validators(heightPtr *int64) (*ctypes.ResultValidators, error) {
// }
// ```
func DumpConsensusState() (*ctypes.ResultDumpConsensusState, error) {
peerRoundStates := make(map[p2p.ID]json.RawMessage)
for _, peer := range p2pSwitch.Peers().List() {
peers := p2pSwitch.Peers().List()
peerRoundStates := make([]ctypes.PeerRoundState, len(peers))
for i, peer := range peers {
peerState := peer.Get(types.PeerStateKey).(*cm.PeerState)
peerRoundState, err := peerState.GetRoundStateJSON()
if err != nil {
return nil, err
}
peerRoundStates[peer.ID()] = peerRoundState
peerRoundStates[i] = ctypes.PeerRoundState{
NodeAddress: p2p.IDAddressString(peer.ID(), peer.NodeInfo().ListenAddr),
PeerRoundState: peerRoundState,
}
}
roundState, err := consensusState.GetRoundStateJSON()
if err != nil {


+ 7
- 2
rpc/core/types/responses.go View File

@ -113,8 +113,13 @@ type ResultValidators struct {
}
type ResultDumpConsensusState struct {
RoundState json.RawMessage `json:"round_state"`
PeerRoundStates map[p2p.ID]json.RawMessage `json:"peer_round_states"`
RoundState json.RawMessage `json:"round_state"`
PeerRoundStates []PeerRoundState `json:"peer_round_states"`
}
type PeerRoundState struct {
NodeAddress string `json:"node_address"`
PeerRoundState json.RawMessage `json:"peer_round_state"`
}
type ResultBroadcastTx struct {


Loading…
Cancel
Save