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.

68 lines
2.5 KiB

  1. package types
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/tendermint/tendermint/libs/bits"
  6. "github.com/tendermint/tendermint/types"
  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 int32 `json:"round"` // Round peer is at, -1 if unknown.
  14. Step RoundStepType `json:"step"` // Step peer is at
  15. // Estimated start of round 0 at this height
  16. StartTime time.Time `json:"start_time"`
  17. // True if peer has proposal for this round
  18. Proposal bool `json:"proposal"`
  19. ProposalBlockPartSetHeader types.PartSetHeader `json:"proposal_block_part_set_header"`
  20. ProposalBlockParts *bits.BitArray `json:"proposal_block_parts"`
  21. // Proposal's POL round. -1 if none.
  22. ProposalPOLRound int32 `json:"proposal_pol_round"`
  23. // nil until ProposalPOLMessage received.
  24. ProposalPOL *bits.BitArray `json:"proposal_pol"`
  25. Prevotes *bits.BitArray `json:"prevotes"` // All votes peer has for this round
  26. Precommits *bits.BitArray `json:"precommits"` // All precommits peer has for this round
  27. LastCommitRound int32 `json:"last_commit_round"` // Round of commit for last height. -1 if none.
  28. LastCommit *bits.BitArray `json:"last_commit"` // All commit precommits of commit for last height.
  29. // Round that we have commit for. Not necessarily unique. -1 if none.
  30. CatchupCommitRound int32 `json:"catchup_commit_round"`
  31. // All commit precommits peer has for this height & CatchupCommitRound
  32. CatchupCommit *bits.BitArray `json:"catchup_commit"`
  33. }
  34. // String returns a string representation of the PeerRoundState
  35. func (prs PeerRoundState) String() string {
  36. return prs.StringIndented("")
  37. }
  38. // StringIndented returns a string representation of the PeerRoundState
  39. func (prs PeerRoundState) StringIndented(indent string) string {
  40. return fmt.Sprintf(`PeerRoundState{
  41. %s %v/%v/%v @%v
  42. %s Proposal %v -> %v
  43. %s POL %v (round %v)
  44. %s Prevotes %v
  45. %s Precommits %v
  46. %s LastCommit %v (round %v)
  47. %s Catchup %v (round %v)
  48. %s}`,
  49. indent, prs.Height, prs.Round, prs.Step, prs.StartTime,
  50. indent, prs.ProposalBlockPartSetHeader, prs.ProposalBlockParts,
  51. indent, prs.ProposalPOL, prs.ProposalPOLRound,
  52. indent, prs.Prevotes,
  53. indent, prs.Precommits,
  54. indent, prs.LastCommit, prs.LastCommitRound,
  55. indent, prs.CatchupCommit, prs.CatchupCommitRound,
  56. indent)
  57. }