You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.9 KiB

  1. package types
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/tendermint/tendermint/types"
  6. cmn "github.com/tendermint/tendermint/libs/common"
  7. )
  8. //-----------------------------------------------------------------------------
  9. // PeerRoundState contains the known state of a peer.
  10. // NOTE: Read-only when returned by PeerState.GetRoundState().
  11. type PeerRoundState struct {
  12. Height int64 `json:"height"` // Height peer is at
  13. Round int `json:"round"` // Round peer is at, -1 if unknown.
  14. Step RoundStepType `json:"step"` // Step peer is at
  15. StartTime time.Time `json:"start_time"` // Estimated start of round 0 at this height
  16. Proposal bool `json:"proposal"` // True if peer has proposal for this round
  17. ProposalBlockPartsHeader types.PartSetHeader `json:"proposal_block_parts_header"` //
  18. ProposalBlockParts *cmn.BitArray `json:"proposal_block_parts"` //
  19. ProposalPOLRound int `json:"proposal_pol_round"` // Proposal's POL round. -1 if none.
  20. ProposalPOL *cmn.BitArray `json:"proposal_pol"` // nil until ProposalPOLMessage received.
  21. Prevotes *cmn.BitArray `json:"prevotes"` // All votes peer has for this round
  22. Precommits *cmn.BitArray `json:"precommits"` // All precommits peer has for this round
  23. LastCommitRound int `json:"last_commit_round"` // Round of commit for last height. -1 if none.
  24. LastCommit *cmn.BitArray `json:"last_commit"` // All commit precommits of commit for last height.
  25. CatchupCommitRound int `json:"catchup_commit_round"` // Round that we have commit for. Not necessarily unique. -1 if none.
  26. CatchupCommit *cmn.BitArray `json:"catchup_commit"` // All commit precommits peer has for this height & CatchupCommitRound
  27. }
  28. // String returns a string representation of the PeerRoundState
  29. func (prs PeerRoundState) String() string {
  30. return prs.StringIndented("")
  31. }
  32. // StringIndented returns a string representation of the PeerRoundState
  33. func (prs PeerRoundState) StringIndented(indent string) string {
  34. return fmt.Sprintf(`PeerRoundState{
  35. %s %v/%v/%v @%v
  36. %s Proposal %v -> %v
  37. %s POL %v (round %v)
  38. %s Prevotes %v
  39. %s Precommits %v
  40. %s LastCommit %v (round %v)
  41. %s Catchup %v (round %v)
  42. %s}`,
  43. indent, prs.Height, prs.Round, prs.Step, prs.StartTime,
  44. indent, prs.ProposalBlockPartsHeader, prs.ProposalBlockParts,
  45. indent, prs.ProposalPOL, prs.ProposalPOLRound,
  46. indent, prs.Prevotes,
  47. indent, prs.Precommits,
  48. indent, prs.LastCommit, prs.LastCommitRound,
  49. indent, prs.CatchupCommit, prs.CatchupCommitRound,
  50. indent)
  51. }