// handleDataMessage handles envelopes sent from peers on the DataChannel. 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.
handleDataMessage handles envelopes sent from peers on the DataChannel. 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.
// handleDataMessage handles envelopes sent from peers on the DataChannel . 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) handleDataMessage(envelope p2p.Envelope, msgI Message) error {
	logger := r.Logger.With("peer", envelope.From, "ch_id", "DataChannel")
	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", fmt.Sprintf("%T", msgI))
		return nil
	}
	switch msg := envelope.Message.(type) {
	case *tmcons.Proposal:
		pMsg := msgI.(*ProposalMessage)
		ps.SetHasProposal(pMsg.Proposal)
		r.state.peerMsgQueue <- msgInfo{pMsg, envelope.From}
	case *tmcons.ProposalPOL:
		ps.ApplyProposalPOLMessage(msgI.(*ProposalPOLMessage))
	case *tmcons.BlockPart:
		bpMsg := msgI.(*BlockPartMessage)
		ps.SetHasProposalBlockPart(bpMsg.Height, bpMsg.Round, int(bpMsg.Part.Index))
		r.Metrics.BlockParts.With("peer_id", string(envelope.From)).Add(1)
		r.state.peerMsgQueue <- msgInfo{bpMsg, envelope.From}
	default:
		return fmt.Errorf("received unknown message on DataChannel: %T", msg)
	}
	return nil
}
func ( r * Reactor ) handleDataMessage ( 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 ( " " , " " , fmt . Sprintf ( " " , msgI ) ) return nil } switch msg := envelope . Message . ( type ) { case * tmcons . Proposal : pMsg := msgI . ( * ProposalMessage ) ps . SetHasProposal ( pMsg . Proposal ) r . state . peerMsgQueue <- msgInfo { pMsg , envelope . From } case * tmcons . ProposalPOL : ps . ApplyProposalPOLMessage ( msgI . ( * ProposalPOLMessage ) ) case * tmcons . BlockPart : bpMsg := msgI . ( * BlockPartMessage ) ps . SetHasProposalBlockPart ( bpMsg . Height , bpMsg . Round , int ( bpMsg . Part . Index ) ) r . Metrics . BlockParts . With ( " " , string ( envelope . From ) ) . Add ( 1 ) r . state . peerMsgQueue <- msgInfo { bpMsg , envelope . From } default : return fmt . Errorf ( " " , msg ) } return nil }
handleDataMessage handles envelopes sent from peers on the DataChannel.
handleDataMessage handles envelopes sent from peers on the DataChannel .