Documentation ¶
Index ¶
- Constants
- Variables
- type ConsensusEvent
- type EventCompleteProposal
- type EventLock
- type EventNewRound
- type EventNewRoundStep
- type EventNewValidBlock
- type EventPolka
- type EventRelock
- type EventTimeoutPropose
- type EventTimeoutWait
- type EventUnlock
- type HRS
- type HeightVoteSet
- func (hvs *HeightVoteSet) AddVote(vote *types.Vote, peerID p2p.ID) (added bool, err error)
- func (hvs *HeightVoteSet) Height() int64
- func (hvs *HeightVoteSet) MarshalJSON() ([]byte, error)
- func (hvs *HeightVoteSet) POLInfo() (polRound int, polBlockID types.BlockID)
- func (hvs *HeightVoteSet) Precommits(round int) *types.VoteSet
- func (hvs *HeightVoteSet) Prevotes(round int) *types.VoteSet
- func (hvs *HeightVoteSet) Reset(height int64, valSet *types.ValidatorSet)
- func (hvs *HeightVoteSet) Round() int
- func (hvs *HeightVoteSet) SetPeerMaj23(round int, type_ types.SignedMsgType, peerID p2p.ID, blockID types.BlockID) error
- func (hvs *HeightVoteSet) SetRound(round int)
- func (hvs *HeightVoteSet) String() string
- func (hvs *HeightVoteSet) StringIndented(indent string) string
- type PeerRoundState
- type RoundState
- func (rs *RoundState) EventCompleteProposal() EventCompleteProposal
- func (rs *RoundState) EventNewRound() EventNewRound
- func (rs *RoundState) EventNewRoundStep() EventNewRoundStep
- func (rs *RoundState) EventNewValidBlock() EventNewValidBlock
- func (rs *RoundState) GetHRS() HRS
- func (rs *RoundState) RoundStateSimple() RoundStateSimple
- func (rs *RoundState) String() string
- func (rs *RoundState) StringIndented(indent string) string
- func (rs *RoundState) StringShort() string
- type RoundStateSimple
- type RoundStepType
- type RoundVoteSet
Constants ¶
const ( RoundStepInvalid = RoundStepType(0x00) // Invalid RoundStepNewHeight = RoundStepType(0x01) // Wait til CommitTime + timeoutCommit RoundStepNewRound = RoundStepType(0x02) // Setup new round and go to RoundStepPropose RoundStepPropose = RoundStepType(0x03) // Did propose, gossip proposal RoundStepPrevote = RoundStepType(0x04) // Did prevote, gossip prevotes RoundStepPrevoteWait = RoundStepType(0x05) // Did receive any +2/3 prevotes, start timeout RoundStepPrecommit = RoundStepType(0x06) // Did precommit, gossip precommits RoundStepPrecommitWait = RoundStepType(0x07) // Did receive any +2/3 precommits, start timeout RoundStepCommit = RoundStepType(0x08) // Entered commit state machine )
RoundStepType
Variables ¶
var (
GotVoteFromUnwantedRoundError = errors.New("Peer has sent a vote that does not match our round for more than one round")
)
var Package = amino.RegisterPackage(amino.NewPackage( "github.com/tendermint/classic/consensus/types", "tm", amino.GetCallersDirname(), ). WithDependencies( abci.Package, ). WithTypes( &RoundState{}, HRS{}, RoundStateSimple{}, PeerRoundState{}, EventNewRoundStep{}, EventNewValidBlock{}, EventNewRound{}, EventCompleteProposal{}, EventTimeoutPropose{}, EventTimeoutWait{}, ))
Functions ¶
This section is empty.
Types ¶
type ConsensusEvent ¶
type EventCompleteProposal ¶
func (EventCompleteProposal) AssertEvent ¶
func (_ EventCompleteProposal) AssertEvent()
func (EventCompleteProposal) String ¶
func (ev EventCompleteProposal) String() string
type EventLock ¶
type EventLock struct {
HRS `json:"hrs"`
}
func (EventLock) AssertEvent ¶
func (_ EventLock) AssertEvent()
type EventNewRound ¶
type EventNewRound struct { HRS `json:"hrs"` Proposer types.Validator `json:"proposer"` ProposerIndex int `json:"proposer_index"` }
func (EventNewRound) AssertEvent ¶
func (_ EventNewRound) AssertEvent()
func (EventNewRound) String ¶
func (ev EventNewRound) String() string
type EventNewRoundStep ¶
type EventNewRoundStep struct { HRS `json:"hrs"` // embed for "GetHRS()" SecondsSinceStartTime int LastCommitRound int }
func (EventNewRoundStep) AssertEvent ¶
func (_ EventNewRoundStep) AssertEvent()
func (EventNewRoundStep) String ¶
func (ev EventNewRoundStep) String() string
type EventNewValidBlock ¶
type EventNewValidBlock struct { HRS `json:"hrs"` BlockPartsHeader types.PartSetHeader `json:"block_parts_header"` BlockParts *cmn.BitArray `json:"block_parts"` IsCommit bool `json:"is_commit"` }
func (EventNewValidBlock) AssertEvent ¶
func (_ EventNewValidBlock) AssertEvent()
func (EventNewValidBlock) String ¶
func (ev EventNewValidBlock) String() string
type EventPolka ¶
type EventPolka struct {
HRS `json:"hrs"`
}
func (EventPolka) AssertEvent ¶
func (_ EventPolka) AssertEvent()
func (EventPolka) String ¶
func (ev EventPolka) String() string
type EventRelock ¶
type EventRelock struct {
HRS `json:"hrs"`
}
func (EventRelock) AssertEvent ¶
func (_ EventRelock) AssertEvent()
func (EventRelock) String ¶
func (ev EventRelock) String() string
type EventTimeoutPropose ¶
type EventTimeoutPropose struct {
HRS `json:"hrs"`
}
func (EventTimeoutPropose) AssertEvent ¶
func (_ EventTimeoutPropose) AssertEvent()
func (EventTimeoutPropose) String ¶
func (ev EventTimeoutPropose) String() string
type EventTimeoutWait ¶
type EventTimeoutWait struct {
HRS `json:"hrs"`
}
func (EventTimeoutWait) AssertEvent ¶
func (_ EventTimeoutWait) AssertEvent()
func (EventTimeoutWait) String ¶
func (ev EventTimeoutWait) String() string
type EventUnlock ¶
type EventUnlock struct {
HRS `json:"hrs"`
}
func (EventUnlock) AssertEvent ¶
func (_ EventUnlock) AssertEvent()
func (EventUnlock) String ¶
func (ev EventUnlock) String() string
type HRS ¶
type HRS struct { Height int64 `json:"height"` Round int `json:"round"` Step RoundStepType `json:"step"` }
type HeightVoteSet ¶
type HeightVoteSet struct {
// contains filtered or unexported fields
}
Keeps track of all VoteSets from round 0 to round 'round'.
Also keeps track of up to one RoundVoteSet greater than 'round' from each peer, to facilitate catchup syncing of commits.
A commit is +2/3 precommits for a block at a round, but which round is not known in advance, so when a peer provides a precommit for a round greater than mtx.round, we create a new entry in roundVoteSets but also remember the peer to prevent abuse. We let each peer provide us with up to 2 unexpected "catchup" rounds. One for their LastCommit round, and another for the official commit round.
func NewHeightVoteSet ¶
func NewHeightVoteSet(chainID string, height int64, valSet *types.ValidatorSet) *HeightVoteSet
func (*HeightVoteSet) AddVote ¶
Duplicate votes return added=false, err=nil. By convention, peerID is "" if origin is self.
func (*HeightVoteSet) Height ¶
func (hvs *HeightVoteSet) Height() int64
func (*HeightVoteSet) MarshalJSON ¶
func (hvs *HeightVoteSet) MarshalJSON() ([]byte, error)
func (*HeightVoteSet) POLInfo ¶
func (hvs *HeightVoteSet) POLInfo() (polRound int, polBlockID types.BlockID)
Last round and blockID that has +2/3 prevotes for a particular block or nil. Returns -1 if no such round exists.
func (*HeightVoteSet) Precommits ¶
func (hvs *HeightVoteSet) Precommits(round int) *types.VoteSet
func (*HeightVoteSet) Reset ¶
func (hvs *HeightVoteSet) Reset(height int64, valSet *types.ValidatorSet)
func (*HeightVoteSet) Round ¶
func (hvs *HeightVoteSet) Round() int
func (*HeightVoteSet) SetPeerMaj23 ¶
func (hvs *HeightVoteSet) SetPeerMaj23(round int, type_ types.SignedMsgType, peerID p2p.ID, blockID types.BlockID) error
If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too
func (*HeightVoteSet) SetRound ¶
func (hvs *HeightVoteSet) SetRound(round int)
Create more RoundVoteSets up to round.
func (*HeightVoteSet) String ¶
func (hvs *HeightVoteSet) String() string
func (*HeightVoteSet) StringIndented ¶
func (hvs *HeightVoteSet) StringIndented(indent string) string
type PeerRoundState ¶
type PeerRoundState struct { 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 }
PeerRoundState contains the known state of a peer. NOTE: Read-only when returned by PeerState.GetRoundState().
func (PeerRoundState) String ¶
func (prs PeerRoundState) String() string
String returns a string representation of the PeerRoundState
func (PeerRoundState) StringIndented ¶
func (prs PeerRoundState) StringIndented(indent string) string
StringIndented returns a string representation of the PeerRoundState
type RoundState ¶
type RoundState struct { // TODO replace w/ HRS Height int64 `json:"height"` // Height we are working on Round int `json:"round"` Step RoundStepType `json:"step"` StartTime time.Time `json:"start_time"` CommitTime time.Time `json:"commit_time"` // Subjective time when +2/3 precommits for Block at Round were found Validators *types.ValidatorSet `json:"validators"` Proposal *types.Proposal `json:"proposal"` ProposalBlock *types.Block `json:"proposal_block"` ProposalBlockParts *types.PartSet `json:"proposal_block_parts"` LockedRound int `json:"locked_round"` LockedBlock *types.Block `json:"locked_block"` LockedBlockParts *types.PartSet `json:"locked_block_parts"` ValidRound int `json:"valid_round"` // Last known round with POL for non-nil valid block. ValidBlock *types.Block `json:"valid_block"` // Last known block of POL mentioned above. ValidBlockParts *types.PartSet `json:"valid_block_parts"` // Last known block parts of POL metnioned above. Votes *HeightVoteSet `json:"votes"` CommitRound int `json:"commit_round"` // LastCommit *types.VoteSet `json:"last_commit"` // Last precommits at Height-1 LastValidators *types.ValidatorSet `json:"last_validators"` TriggeredTimeoutPrecommit bool `json:"triggered_timeout_precommit"` }
RoundState defines the internal consensus state. NOTE: Not thread safe. Should only be manipulated by functions downstream of the cs.receiveRoutine
func (*RoundState) EventCompleteProposal ¶
func (rs *RoundState) EventCompleteProposal() EventCompleteProposal
EventCompleteProposal returns information about a proposed block as an event.
func (*RoundState) EventNewRound ¶
func (rs *RoundState) EventNewRound() EventNewRound
EventNewRound returns the RoundState with proposer information as an event.
func (*RoundState) EventNewRoundStep ¶
func (rs *RoundState) EventNewRoundStep() EventNewRoundStep
func (*RoundState) EventNewValidBlock ¶
func (rs *RoundState) EventNewValidBlock() EventNewValidBlock
func (*RoundState) GetHRS ¶
func (rs *RoundState) GetHRS() HRS
func (*RoundState) RoundStateSimple ¶
func (rs *RoundState) RoundStateSimple() RoundStateSimple
Compress the RoundState to RoundStateSimple
func (*RoundState) StringIndented ¶
func (rs *RoundState) StringIndented(indent string) string
StringIndented returns a string
func (*RoundState) StringShort ¶
func (rs *RoundState) StringShort() string
StringShort returns a string
type RoundStateSimple ¶
type RoundStateSimple struct { HeightRoundStep string `json:"height/round/step"` StartTime time.Time `json:"start_time"` ProposalBlockHash []byte `json:"proposal_block_hash"` LockedBlockHash []byte `json:"locked_block_hash"` ValidBlockHash []byte `json:"valid_block_hash"` Votes json.RawMessage `json:"height_vote_set"` }
Compressed version of the RoundState for use in RPC
type RoundStepType ¶
type RoundStepType uint8 // These must be numeric, ordered.
RoundStepType enumerates the state of the consensus state machine
func (RoundStepType) IsValid ¶
func (rs RoundStepType) IsValid() bool
IsValid returns true if the step is valid, false if unknown/undefined.