// handleVoteMessage handles envelopes sent from peers on the VoteChannel. If we
// fail to find the peer state for the envelope sender, we perform a no-op and
// return. This can happen when we process the envelope after the peer is
// removed.
handleVoteMessage handles envelopes sent from peers on the VoteChannel. If we
fail to find the peer state for the envelope sender, we perform a no-op and
return. This can happen when we process the envelope after the peer is
removed.
// handleVoteMessage handles envelopes sent from peers on the VoteChannel . If we // fail to find the peer state for the envelope sender we perform a no - op and // return . This can happen when we process the envelope after the peer is // removed .
func (r *Reactor) handleVoteMessage(envelope p2p.Envelope, msgI Message) error {
	logger := r.Logger.With("peer", envelope.From, "ch_id", "VoteChannel")
	ps, ok := r.GetPeerState(envelope.From)
	if !ok || ps == nil {
		r.Logger.Debug("failed to find peer state")
		return nil
	}
	if r.WaitSync() {
		logger.Info("ignoring message received during sync", "msg", msgI)
		return nil
	}
	switch msg := envelope.Message.(type) {
	case *tmcons.Vote:
		r.state.mtx.RLock()
		height, valSize, lastCommitSize := r.state.Height, r.state.Validators.Size(), r.state.LastCommit.Size()
		r.state.mtx.RUnlock()
		vMsg := msgI.(*VoteMessage)
		ps.EnsureVoteBitArrays(height, valSize)
		ps.EnsureVoteBitArrays(height-1, lastCommitSize)
		ps.SetHasVote(vMsg.Vote)
		r.state.peerMsgQueue <- msgInfo{vMsg, envelope.From}
	default:
		return fmt.Errorf("received unknown message on VoteChannel: %T", msg)
	}
	return nil
}
func ( r * Reactor ) handleVoteMessage ( envelope p2p . Envelope , msgI Message ) error { logger := r . Logger . With ( " " , envelope . From , " " , " " ) ps , ok := r . GetPeerState ( envelope . From ) if ! ok || ps == nil { r . Logger . Debug ( " " ) return nil } if r . WaitSync ( ) { logger . Info ( " " , " " , msgI ) return nil } switch msg := envelope . Message . ( type ) { case * tmcons . Vote : r . state . mtx . RLock ( ) height , valSize , lastCommitSize := r . state . Height , r . state . Validators . Size ( ) , r . state . LastCommit . Size ( ) r . state . mtx . RUnlock ( ) vMsg := msgI . ( * VoteMessage ) ps . EnsureVoteBitArrays ( height , valSize ) ps . EnsureVoteBitArrays ( height - 1 , lastCommitSize ) ps . SetHasVote ( vMsg . Vote ) r . state . peerMsgQueue <- msgInfo { vMsg , envelope . From } default : return fmt . Errorf ( " " , msg ) } return nil }
handleVoteMessage handles envelopes sent from peers on the VoteChannel.
handleVoteMessage handles envelopes sent from peers on the VoteChannel .