// processStateCh initiates a blocking process where we listen for and handle
// envelopes on the StateChannel. Any error encountered during message
// execution will result in a PeerError being sent on the StateChannel. When
// the reactor is stopped, we will catch the signal and close the p2p Channel
// gracefully.
processStateCh initiates a blocking process where we listen for and handle
envelopes on the StateChannel. Any error encountered during message
execution will result in a PeerError being sent on the StateChannel. When
the reactor is stopped, we will catch the signal and close the p2p Channel
gracefully.
// processStateCh initiates a blocking process where we listen for and handle // envelopes on the StateChannel . Any error encountered during message // execution will result in a PeerError being sent on the StateChannel . When // the reactor is stopped we will catch the signal and close the p2p Channel // gracefully .
func (r *Reactor) processStateCh() {
	defer r.stateCh.Close()
	for {
		select {
		case envelope := <-r.stateCh.In:
			if err := r.handleMessage(r.stateCh.ID, envelope); err != nil {
				r.Logger.Error("failed to process message", "ch_id", r.stateCh.ID, "envelope", envelope, "err", err)
				r.stateCh.Error <- p2p.PeerError{
					NodeID: envelope.From,
					Err:    err,
				}
			}
		case <-r.stateCloseCh:
			r.Logger.Debug("stopped listening on StateChannel; closing...")
			return
		}
	}
}
func ( r * Reactor ) processStateCh ( ) { defer r . stateCh . Close ( ) for { select { case envelope := <- r . stateCh . In : if err := r . handleMessage ( r . stateCh . ID , envelope ) ; err != nil { r . Logger . Error ( " " , " " , r . stateCh . ID , " " , envelope , " " , err ) r . stateCh . Error <- p2p . PeerError { NodeID : envelope . From , Err : err , } } case <- r . stateCloseCh : r . Logger . Debug ( " " ) return } } }
processStateCh initiates a blocking process where we listen for and handle
envelopes on the StateChannel.
processStateCh initiates a blocking process where we listen for and handle envelopes on the StateChannel .