func (op *obcSieve) main() {
	for {
		select {
		case msgWithSender := <-op.incomingChan:

			if err := op.recvMsg(msgWithSender.msg, msgWithSender.sender); nil != err {
				logger.Error("Could not process message: %v", err)
			}

		case exec := <-op.executeChan:
			op.executeImpl(exec.seqNo, exec.txRaw)
		case <-op.pbft.closed:
			logger.Debug("Sieve replica %d requested to stop", op.id)
			close(op.idleChan)
			return
		case update := <-op.stateUpdatingChan:
			op.pbft.stateUpdating(update.seqNo, update.id)
		case update := <-op.stateUpdatedChan:
			op.restoreBlockNumber()

			op.lastExecPbftSeqNo = update.seqNo

			op.pbft.stateUpdated(update.seqNo, update.id)

			if op.execOutstanding {
				op.pbft.execDone()
				op.execDone()
			}
		case c := <-op.custodyTimerChan:
			if !c.complaint {
				logger.Warning("Sieve replica %d custody expired, complaining: %s", op.id, c.hash)
				op.broadcastMsg(&SieveMessage{&SieveMessage_Complaint{c.req.(*Request)}})
			} else {
				if op.pbft.activeView {
					logger.Debug("Sieve replica %d complaint timeout expired for %s", op.id, c.hash)
					op.pbft.sendViewChange()
				}
			}
		case op.idleChan <- struct{}{}:
			// Only used for detecting idleness in unit tests
		}
	}
}
// The main single loop which the sieve thread traverses
The main single loop which the sieve thread traverses
// The main single loop which the sieve thread traverses
func (op *obcSieve) main() {
	for {
		select {
		case msgWithSender := <-op.incomingChan:
			if err := op.recvMsg(msgWithSender.msg, msgWithSender.sender); nil != err {
				logger.Error("Could not process message: %v", err)
			}
		case exec := <-op.executeChan:
			op.executeImpl(exec.seqNo, exec.txRaw)
		case <-op.pbft.closed:
			logger.Debug("Sieve replica %d requested to stop", op.id)
			close(op.idleChan)
			return
		case update := <-op.stateUpdatingChan:
			op.pbft.stateUpdating(update.seqNo, update.id)
		case update := <-op.stateUpdatedChan:
			op.restoreBlockNumber()
			op.lastExecPbftSeqNo = update.seqNo
			op.pbft.stateUpdated(update.seqNo, update.id)
			if op.execOutstanding {
				op.pbft.execDone()
				op.execDone()
			}
		case c := <-op.custodyTimerChan:
			if !c.complaint {
				logger.Warning("Sieve replica %d custody expired, complaining: %s", op.id, c.hash)
				op.broadcastMsg(&SieveMessage{&SieveMessage_Complaint{c.req.(*Request)}})
			} else {
				if op.pbft.activeView {
					logger.Debug("Sieve replica %d complaint timeout expired for %s", op.id, c.hash)
					op.pbft.sendViewChange()
				}
			}
		case op.idleChan <- struct{}{}:
		}
	}
}
func ( op * obcSieve ) main ( ) { for { select { case msgWithSender := <- op . incomingChan : if err := op . recvMsg ( msgWithSender . msg , msgWithSender . sender ) ; nil != err { logger . Error ( " " , err ) } case exec := <- op . executeChan : op . executeImpl ( exec . seqNo , exec . txRaw ) case <- op . pbft . closed : logger . Debug ( " " , op . id ) close ( op . idleChan ) return case update := <- op . stateUpdatingChan : op . pbft . stateUpdating ( update . seqNo , update . id ) case update := <- op . stateUpdatedChan : op . restoreBlockNumber ( ) op . lastExecPbftSeqNo = update . seqNo op . pbft . stateUpdated ( update . seqNo , update . id ) if op . execOutstanding { op . pbft . execDone ( ) op . execDone ( ) } case c := <- op . custodyTimerChan : if ! c . complaint { logger . Warning ( " " , op . id , c . hash ) op . broadcastMsg ( & SieveMessage { & SieveMessage_Complaint { c . req . ( * Request ) } } ) } else { if op . pbft . activeView { logger . Debug ( " " , op . id , c . hash ) op . pbft . sendViewChange ( ) } } case op . idleChan <- struct { } { } : } } }
The main single loop which the sieve thread traverses
The main single loop which the sieve thread traverses
// Only used for detecting idleness in unit tests