github.com/vipernet-xyz/tm@v0.34.24/consensus/types/peer_round_state.go (about)

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