|
|
@ -210,7 +210,7 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) |
|
|
|
return |
|
|
|
} |
|
|
|
// Peer claims to have a maj23 for some BlockID at H,R,S,
|
|
|
|
err := votes.SetPeerMaj23(msg.Round, msg.Type, ps.Peer.ID(), msg.BlockID) |
|
|
|
err := votes.SetPeerMaj23(msg.Round, msg.Type, ps.peer.ID(), msg.BlockID) |
|
|
|
if err != nil { |
|
|
|
conR.Switch.StopPeerForError(src, err) |
|
|
|
return |
|
|
@ -840,41 +840,42 @@ var ( |
|
|
|
|
|
|
|
// PeerState contains the known state of a peer, including its connection and
|
|
|
|
// threadsafe access to its PeerRoundState.
|
|
|
|
// NOTE: THIS GETS DUMPED WITH rpc/core/consensus.go.
|
|
|
|
// Be mindful of what you Expose.
|
|
|
|
type PeerState struct { |
|
|
|
Peer p2p.Peer |
|
|
|
peer p2p.Peer |
|
|
|
logger log.Logger |
|
|
|
|
|
|
|
mtx sync.Mutex |
|
|
|
cstypes.PeerRoundState |
|
|
|
|
|
|
|
stats *peerStateStats |
|
|
|
mtx sync.Mutex `json:"-"` // NOTE: Modify below using setters, never directly.
|
|
|
|
PRS cstypes.PeerRoundState `json:"round_state"` // Exposed.
|
|
|
|
Stats *peerStateStats `json:"stats"` // Exposed.
|
|
|
|
} |
|
|
|
|
|
|
|
// peerStateStats holds internal statistics for a peer.
|
|
|
|
type peerStateStats struct { |
|
|
|
lastVoteHeight int64 |
|
|
|
votes int |
|
|
|
|
|
|
|
lastBlockPartHeight int64 |
|
|
|
blockParts int |
|
|
|
LastVoteHeight int64 `json:"last_vote_height"` |
|
|
|
Votes int `json:"votes"` |
|
|
|
LastBlockPartHeight int64 `json:"last_block_part_height"` |
|
|
|
BlockParts int `json:"block_parts"` |
|
|
|
} |
|
|
|
|
|
|
|
func (pss peerStateStats) String() string { |
|
|
|
return fmt.Sprintf("peerStateStats{votes: %d, blockParts: %d}", pss.votes, pss.blockParts) |
|
|
|
return fmt.Sprintf("peerStateStats{lvh: %d, votes: %d, lbph: %d, blockParts: %d}", |
|
|
|
pss.LastVoteHeight, pss.Votes, pss.LastBlockPartHeight, pss.BlockParts) |
|
|
|
} |
|
|
|
|
|
|
|
// NewPeerState returns a new PeerState for the given Peer
|
|
|
|
func NewPeerState(peer p2p.Peer) *PeerState { |
|
|
|
return &PeerState{ |
|
|
|
Peer: peer, |
|
|
|
peer: peer, |
|
|
|
logger: log.NewNopLogger(), |
|
|
|
PeerRoundState: cstypes.PeerRoundState{ |
|
|
|
PRS: cstypes.PeerRoundState{ |
|
|
|
Round: -1, |
|
|
|
ProposalPOLRound: -1, |
|
|
|
LastCommitRound: -1, |
|
|
|
CatchupCommitRound: -1, |
|
|
|
}, |
|
|
|
stats: &peerStateStats{}, |
|
|
|
Stats: &peerStateStats{}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -891,16 +892,16 @@ func (ps *PeerState) GetRoundState() *cstypes.PeerRoundState { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
prs := ps.PeerRoundState // copy
|
|
|
|
prs := ps.PRS // copy
|
|
|
|
return &prs |
|
|
|
} |
|
|
|
|
|
|
|
// GetRoundStateJSON returns a json of PeerRoundState, marshalled using go-amino.
|
|
|
|
func (ps *PeerState) GetRoundStateJSON() ([]byte, error) { |
|
|
|
// ToJSON returns a json of PeerState, marshalled using go-amino.
|
|
|
|
func (ps *PeerState) ToJSON() ([]byte, error) { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
return cdc.MarshalJSON(ps.PeerRoundState) |
|
|
|
return cdc.MarshalJSON(ps) |
|
|
|
} |
|
|
|
|
|
|
|
// GetHeight returns an atomic snapshot of the PeerRoundState's height
|
|
|
@ -908,7 +909,7 @@ func (ps *PeerState) GetRoundStateJSON() ([]byte, error) { |
|
|
|
func (ps *PeerState) GetHeight() int64 { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
return ps.PeerRoundState.Height |
|
|
|
return ps.PRS.Height |
|
|
|
} |
|
|
|
|
|
|
|
// SetHasProposal sets the given proposal as known for the peer.
|
|
|
@ -916,18 +917,18 @@ func (ps *PeerState) SetHasProposal(proposal *types.Proposal) { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
if ps.Height != proposal.Height || ps.Round != proposal.Round { |
|
|
|
if ps.PRS.Height != proposal.Height || ps.PRS.Round != proposal.Round { |
|
|
|
return |
|
|
|
} |
|
|
|
if ps.Proposal { |
|
|
|
if ps.PRS.Proposal { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ps.Proposal = true |
|
|
|
ps.ProposalBlockPartsHeader = proposal.BlockPartsHeader |
|
|
|
ps.ProposalBlockParts = cmn.NewBitArray(proposal.BlockPartsHeader.Total) |
|
|
|
ps.ProposalPOLRound = proposal.POLRound |
|
|
|
ps.ProposalPOL = nil // Nil until ProposalPOLMessage received.
|
|
|
|
ps.PRS.Proposal = true |
|
|
|
ps.PRS.ProposalBlockPartsHeader = proposal.BlockPartsHeader |
|
|
|
ps.PRS.ProposalBlockParts = cmn.NewBitArray(proposal.BlockPartsHeader.Total) |
|
|
|
ps.PRS.ProposalPOLRound = proposal.POLRound |
|
|
|
ps.PRS.ProposalPOL = nil // Nil until ProposalPOLMessage received.
|
|
|
|
} |
|
|
|
|
|
|
|
// InitProposalBlockParts initializes the peer's proposal block parts header and bit array.
|
|
|
@ -935,12 +936,12 @@ func (ps *PeerState) InitProposalBlockParts(partsHeader types.PartSetHeader) { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
if ps.ProposalBlockParts != nil { |
|
|
|
if ps.PRS.ProposalBlockParts != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ps.ProposalBlockPartsHeader = partsHeader |
|
|
|
ps.ProposalBlockParts = cmn.NewBitArray(partsHeader.Total) |
|
|
|
ps.PRS.ProposalBlockPartsHeader = partsHeader |
|
|
|
ps.PRS.ProposalBlockParts = cmn.NewBitArray(partsHeader.Total) |
|
|
|
} |
|
|
|
|
|
|
|
// SetHasProposalBlockPart sets the given block part index as known for the peer.
|
|
|
@ -948,11 +949,11 @@ func (ps *PeerState) SetHasProposalBlockPart(height int64, round int, index int) |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
if ps.Height != height || ps.Round != round { |
|
|
|
if ps.PRS.Height != height || ps.PRS.Round != round { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ps.ProposalBlockParts.SetIndex(index, true) |
|
|
|
ps.PRS.ProposalBlockParts.SetIndex(index, true) |
|
|
|
} |
|
|
|
|
|
|
|
// PickSendVote picks a vote and sends it to the peer.
|
|
|
@ -961,7 +962,7 @@ func (ps *PeerState) PickSendVote(votes types.VoteSetReader) bool { |
|
|
|
if vote, ok := ps.PickVoteToSend(votes); ok { |
|
|
|
msg := &VoteMessage{vote} |
|
|
|
ps.logger.Debug("Sending vote message", "ps", ps, "vote", vote) |
|
|
|
return ps.Peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(msg)) |
|
|
|
return ps.peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(msg)) |
|
|
|
} |
|
|
|
return false |
|
|
|
} |
|
|
@ -1001,40 +1002,40 @@ func (ps *PeerState) getVoteBitArray(height int64, round int, type_ byte) *cmn.B |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
if ps.Height == height { |
|
|
|
if ps.Round == round { |
|
|
|
if ps.PRS.Height == height { |
|
|
|
if ps.PRS.Round == round { |
|
|
|
switch type_ { |
|
|
|
case types.VoteTypePrevote: |
|
|
|
return ps.Prevotes |
|
|
|
return ps.PRS.Prevotes |
|
|
|
case types.VoteTypePrecommit: |
|
|
|
return ps.Precommits |
|
|
|
return ps.PRS.Precommits |
|
|
|
} |
|
|
|
} |
|
|
|
if ps.CatchupCommitRound == round { |
|
|
|
if ps.PRS.CatchupCommitRound == round { |
|
|
|
switch type_ { |
|
|
|
case types.VoteTypePrevote: |
|
|
|
return nil |
|
|
|
case types.VoteTypePrecommit: |
|
|
|
return ps.CatchupCommit |
|
|
|
return ps.PRS.CatchupCommit |
|
|
|
} |
|
|
|
} |
|
|
|
if ps.ProposalPOLRound == round { |
|
|
|
if ps.PRS.ProposalPOLRound == round { |
|
|
|
switch type_ { |
|
|
|
case types.VoteTypePrevote: |
|
|
|
return ps.ProposalPOL |
|
|
|
return ps.PRS.ProposalPOL |
|
|
|
case types.VoteTypePrecommit: |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
if ps.Height == height+1 { |
|
|
|
if ps.LastCommitRound == round { |
|
|
|
if ps.PRS.Height == height+1 { |
|
|
|
if ps.PRS.LastCommitRound == round { |
|
|
|
switch type_ { |
|
|
|
case types.VoteTypePrevote: |
|
|
|
return nil |
|
|
|
case types.VoteTypePrecommit: |
|
|
|
return ps.LastCommit |
|
|
|
return ps.PRS.LastCommit |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
@ -1044,7 +1045,7 @@ func (ps *PeerState) getVoteBitArray(height int64, round int, type_ byte) *cmn.B |
|
|
|
|
|
|
|
// 'round': A round for which we have a +2/3 commit.
|
|
|
|
func (ps *PeerState) ensureCatchupCommitRound(height int64, round int, numValidators int) { |
|
|
|
if ps.Height != height { |
|
|
|
if ps.PRS.Height != height { |
|
|
|
return |
|
|
|
} |
|
|
|
/* |
|
|
@ -1054,14 +1055,14 @@ func (ps *PeerState) ensureCatchupCommitRound(height int64, round int, numValida |
|
|
|
cmn.PanicSanity(cmn.Fmt("Conflicting CatchupCommitRound. Height: %v, Orig: %v, New: %v", height, ps.CatchupCommitRound, round)) |
|
|
|
} |
|
|
|
*/ |
|
|
|
if ps.CatchupCommitRound == round { |
|
|
|
if ps.PRS.CatchupCommitRound == round { |
|
|
|
return // Nothing to do!
|
|
|
|
} |
|
|
|
ps.CatchupCommitRound = round |
|
|
|
if round == ps.Round { |
|
|
|
ps.CatchupCommit = ps.Precommits |
|
|
|
ps.PRS.CatchupCommitRound = round |
|
|
|
if round == ps.PRS.Round { |
|
|
|
ps.PRS.CatchupCommit = ps.PRS.Precommits |
|
|
|
} else { |
|
|
|
ps.CatchupCommit = cmn.NewBitArray(numValidators) |
|
|
|
ps.PRS.CatchupCommit = cmn.NewBitArray(numValidators) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1076,22 +1077,22 @@ func (ps *PeerState) EnsureVoteBitArrays(height int64, numValidators int) { |
|
|
|
} |
|
|
|
|
|
|
|
func (ps *PeerState) ensureVoteBitArrays(height int64, numValidators int) { |
|
|
|
if ps.Height == height { |
|
|
|
if ps.Prevotes == nil { |
|
|
|
ps.Prevotes = cmn.NewBitArray(numValidators) |
|
|
|
if ps.PRS.Height == height { |
|
|
|
if ps.PRS.Prevotes == nil { |
|
|
|
ps.PRS.Prevotes = cmn.NewBitArray(numValidators) |
|
|
|
} |
|
|
|
if ps.Precommits == nil { |
|
|
|
ps.Precommits = cmn.NewBitArray(numValidators) |
|
|
|
if ps.PRS.Precommits == nil { |
|
|
|
ps.PRS.Precommits = cmn.NewBitArray(numValidators) |
|
|
|
} |
|
|
|
if ps.CatchupCommit == nil { |
|
|
|
ps.CatchupCommit = cmn.NewBitArray(numValidators) |
|
|
|
if ps.PRS.CatchupCommit == nil { |
|
|
|
ps.PRS.CatchupCommit = cmn.NewBitArray(numValidators) |
|
|
|
} |
|
|
|
if ps.ProposalPOL == nil { |
|
|
|
ps.ProposalPOL = cmn.NewBitArray(numValidators) |
|
|
|
if ps.PRS.ProposalPOL == nil { |
|
|
|
ps.PRS.ProposalPOL = cmn.NewBitArray(numValidators) |
|
|
|
} |
|
|
|
} else if ps.Height == height+1 { |
|
|
|
if ps.LastCommit == nil { |
|
|
|
ps.LastCommit = cmn.NewBitArray(numValidators) |
|
|
|
} else if ps.PRS.Height == height+1 { |
|
|
|
if ps.PRS.LastCommit == nil { |
|
|
|
ps.PRS.LastCommit = cmn.NewBitArray(numValidators) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1103,12 +1104,12 @@ func (ps *PeerState) RecordVote(vote *types.Vote) int { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
if ps.stats.lastVoteHeight >= vote.Height { |
|
|
|
return ps.stats.votes |
|
|
|
if ps.Stats.LastVoteHeight >= vote.Height { |
|
|
|
return ps.Stats.Votes |
|
|
|
} |
|
|
|
ps.stats.lastVoteHeight = vote.Height |
|
|
|
ps.stats.votes++ |
|
|
|
return ps.stats.votes |
|
|
|
ps.Stats.LastVoteHeight = vote.Height |
|
|
|
ps.Stats.Votes++ |
|
|
|
return ps.Stats.Votes |
|
|
|
} |
|
|
|
|
|
|
|
// VotesSent returns the number of blocks for which peer has been sending us
|
|
|
@ -1117,7 +1118,7 @@ func (ps *PeerState) VotesSent() int { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
return ps.stats.votes |
|
|
|
return ps.Stats.Votes |
|
|
|
} |
|
|
|
|
|
|
|
// RecordBlockPart updates internal statistics for this peer by recording the
|
|
|
@ -1128,13 +1129,13 @@ func (ps *PeerState) RecordBlockPart(bp *BlockPartMessage) int { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
if ps.stats.lastBlockPartHeight >= bp.Height { |
|
|
|
return ps.stats.blockParts |
|
|
|
if ps.Stats.LastBlockPartHeight >= bp.Height { |
|
|
|
return ps.Stats.BlockParts |
|
|
|
} |
|
|
|
|
|
|
|
ps.stats.lastBlockPartHeight = bp.Height |
|
|
|
ps.stats.blockParts++ |
|
|
|
return ps.stats.blockParts |
|
|
|
ps.Stats.LastBlockPartHeight = bp.Height |
|
|
|
ps.Stats.BlockParts++ |
|
|
|
return ps.Stats.BlockParts |
|
|
|
} |
|
|
|
|
|
|
|
// BlockPartsSent returns the number of blocks for which peer has been sending
|
|
|
@ -1143,7 +1144,7 @@ func (ps *PeerState) BlockPartsSent() int { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
return ps.stats.blockParts |
|
|
|
return ps.Stats.BlockParts |
|
|
|
} |
|
|
|
|
|
|
|
// SetHasVote sets the given vote as known by the peer
|
|
|
@ -1155,7 +1156,7 @@ func (ps *PeerState) SetHasVote(vote *types.Vote) { |
|
|
|
} |
|
|
|
|
|
|
|
func (ps *PeerState) setHasVote(height int64, round int, type_ byte, index int) { |
|
|
|
logger := ps.logger.With("peerH/R", cmn.Fmt("%d/%d", ps.Height, ps.Round), "H/R", cmn.Fmt("%d/%d", height, round)) |
|
|
|
logger := ps.logger.With("peerH/R", cmn.Fmt("%d/%d", ps.PRS.Height, ps.PRS.Round), "H/R", cmn.Fmt("%d/%d", height, round)) |
|
|
|
logger.Debug("setHasVote", "type", type_, "index", index) |
|
|
|
|
|
|
|
// NOTE: some may be nil BitArrays -> no side effects.
|
|
|
@ -1171,51 +1172,51 @@ func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage) { |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
// Ignore duplicates or decreases
|
|
|
|
if CompareHRS(msg.Height, msg.Round, msg.Step, ps.Height, ps.Round, ps.Step) <= 0 { |
|
|
|
if CompareHRS(msg.Height, msg.Round, msg.Step, ps.PRS.Height, ps.PRS.Round, ps.PRS.Step) <= 0 { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// Just remember these values.
|
|
|
|
psHeight := ps.Height |
|
|
|
psRound := ps.Round |
|
|
|
//psStep := ps.Step
|
|
|
|
psCatchupCommitRound := ps.CatchupCommitRound |
|
|
|
psCatchupCommit := ps.CatchupCommit |
|
|
|
psHeight := ps.PRS.Height |
|
|
|
psRound := ps.PRS.Round |
|
|
|
//psStep := ps.PRS.Step
|
|
|
|
psCatchupCommitRound := ps.PRS.CatchupCommitRound |
|
|
|
psCatchupCommit := ps.PRS.CatchupCommit |
|
|
|
|
|
|
|
startTime := time.Now().Add(-1 * time.Duration(msg.SecondsSinceStartTime) * time.Second) |
|
|
|
ps.Height = msg.Height |
|
|
|
ps.Round = msg.Round |
|
|
|
ps.Step = msg.Step |
|
|
|
ps.StartTime = startTime |
|
|
|
ps.PRS.Height = msg.Height |
|
|
|
ps.PRS.Round = msg.Round |
|
|
|
ps.PRS.Step = msg.Step |
|
|
|
ps.PRS.StartTime = startTime |
|
|
|
if psHeight != msg.Height || psRound != msg.Round { |
|
|
|
ps.Proposal = false |
|
|
|
ps.ProposalBlockPartsHeader = types.PartSetHeader{} |
|
|
|
ps.ProposalBlockParts = nil |
|
|
|
ps.ProposalPOLRound = -1 |
|
|
|
ps.ProposalPOL = nil |
|
|
|
ps.PRS.Proposal = false |
|
|
|
ps.PRS.ProposalBlockPartsHeader = types.PartSetHeader{} |
|
|
|
ps.PRS.ProposalBlockParts = nil |
|
|
|
ps.PRS.ProposalPOLRound = -1 |
|
|
|
ps.PRS.ProposalPOL = nil |
|
|
|
// We'll update the BitArray capacity later.
|
|
|
|
ps.Prevotes = nil |
|
|
|
ps.Precommits = nil |
|
|
|
ps.PRS.Prevotes = nil |
|
|
|
ps.PRS.Precommits = nil |
|
|
|
} |
|
|
|
if psHeight == msg.Height && psRound != msg.Round && msg.Round == psCatchupCommitRound { |
|
|
|
// Peer caught up to CatchupCommitRound.
|
|
|
|
// Preserve psCatchupCommit!
|
|
|
|
// NOTE: We prefer to use prs.Precommits if
|
|
|
|
// pr.Round matches pr.CatchupCommitRound.
|
|
|
|
ps.Precommits = psCatchupCommit |
|
|
|
ps.PRS.Precommits = psCatchupCommit |
|
|
|
} |
|
|
|
if psHeight != msg.Height { |
|
|
|
// Shift Precommits to LastCommit.
|
|
|
|
if psHeight+1 == msg.Height && psRound == msg.LastCommitRound { |
|
|
|
ps.LastCommitRound = msg.LastCommitRound |
|
|
|
ps.LastCommit = ps.Precommits |
|
|
|
ps.PRS.LastCommitRound = msg.LastCommitRound |
|
|
|
ps.PRS.LastCommit = ps.PRS.Precommits |
|
|
|
} else { |
|
|
|
ps.LastCommitRound = msg.LastCommitRound |
|
|
|
ps.LastCommit = nil |
|
|
|
ps.PRS.LastCommitRound = msg.LastCommitRound |
|
|
|
ps.PRS.LastCommit = nil |
|
|
|
} |
|
|
|
// We'll update the BitArray capacity later.
|
|
|
|
ps.CatchupCommitRound = -1 |
|
|
|
ps.CatchupCommit = nil |
|
|
|
ps.PRS.CatchupCommitRound = -1 |
|
|
|
ps.PRS.CatchupCommit = nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1224,12 +1225,12 @@ func (ps *PeerState) ApplyCommitStepMessage(msg *CommitStepMessage) { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
if ps.Height != msg.Height { |
|
|
|
if ps.PRS.Height != msg.Height { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ps.ProposalBlockPartsHeader = msg.BlockPartsHeader |
|
|
|
ps.ProposalBlockParts = msg.BlockParts |
|
|
|
ps.PRS.ProposalBlockPartsHeader = msg.BlockPartsHeader |
|
|
|
ps.PRS.ProposalBlockParts = msg.BlockParts |
|
|
|
} |
|
|
|
|
|
|
|
// ApplyProposalPOLMessage updates the peer state for the new proposal POL.
|
|
|
@ -1237,16 +1238,16 @@ func (ps *PeerState) ApplyProposalPOLMessage(msg *ProposalPOLMessage) { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
if ps.Height != msg.Height { |
|
|
|
if ps.PRS.Height != msg.Height { |
|
|
|
return |
|
|
|
} |
|
|
|
if ps.ProposalPOLRound != msg.ProposalPOLRound { |
|
|
|
if ps.PRS.ProposalPOLRound != msg.ProposalPOLRound { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: Merge onto existing ps.ProposalPOL?
|
|
|
|
// TODO: Merge onto existing ps.PRS.ProposalPOL?
|
|
|
|
// We might have sent some prevotes in the meantime.
|
|
|
|
ps.ProposalPOL = msg.ProposalPOL |
|
|
|
ps.PRS.ProposalPOL = msg.ProposalPOL |
|
|
|
} |
|
|
|
|
|
|
|
// ApplyHasVoteMessage updates the peer state for the new vote.
|
|
|
@ -1254,7 +1255,7 @@ func (ps *PeerState) ApplyHasVoteMessage(msg *HasVoteMessage) { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
|
|
|
|
if ps.Height != msg.Height { |
|
|
|
if ps.PRS.Height != msg.Height { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
@ -1292,13 +1293,13 @@ func (ps *PeerState) StringIndented(indent string) string { |
|
|
|
ps.mtx.Lock() |
|
|
|
defer ps.mtx.Unlock() |
|
|
|
return fmt.Sprintf(`PeerState{ |
|
|
|
%s Key %v |
|
|
|
%s PRS %v |
|
|
|
%s Stats %v |
|
|
|
%s Key %v |
|
|
|
%s RoundState %v |
|
|
|
%s Stats %v |
|
|
|
%s}`, |
|
|
|
indent, ps.Peer.ID(), |
|
|
|
indent, ps.PeerRoundState.StringIndented(indent+" "), |
|
|
|
indent, ps.stats, |
|
|
|
indent, ps.peer.ID(), |
|
|
|
indent, ps.PRS.StringIndented(indent+" "), |
|
|
|
indent, ps.Stats, |
|
|
|
indent) |
|
|
|
} |
|
|
|
|
|
|
|