MCPcopy Create free account
hub / github.com/DNAProject/DNA / start

Method start

txnpool/proc/txnpool_worker.go:302–331  ·  view source on GitHub ↗

Start is the main event loop.

()

Source from the content-addressed store, hash-verified

300
301// Start is the main event loop.
302func (worker *txPoolWorker) start() {
303 worker.timer = time.NewTimer(time.Second * tc.EXPIRE_INTERVAL)
304 for {
305 select {
306 case <-worker.stopCh:
307 worker.server.wg.Done()
308 return
309 case rcvTx, ok := <-worker.rcvTXCh:
310 if ok {
311 // Verify rcvTxn
312 worker.verifyTx(rcvTx)
313 }
314 case stfTx, ok := <-worker.stfTxCh:
315 if ok {
316 worker.verifyStateful(stfTx)
317 }
318 case <-worker.timer.C:
319 worker.handleTimeoutEvent()
320 worker.timer.Stop()
321 worker.timer.Reset(time.Second * tc.EXPIRE_INTERVAL)
322 case rsp, ok := <-worker.rspCh:
323 if ok {
324 /* Handle the response from validator, if all of cases
325 * are verified, put it to txnPool
326 */
327 worker.handleRsp(rsp)
328 }
329 }
330 }
331}
332
333// stop closes/releases channels and stops timer
334func (worker *txPoolWorker) stop() {

Callers 2

TestWorkerFunction · 0.95
initMethod · 0.45

Calls 6

verifyTxMethod · 0.95
verifyStatefulMethod · 0.95
handleTimeoutEventMethod · 0.95
handleRspMethod · 0.95
StopMethod · 0.65
ResetMethod · 0.45

Tested by 1

TestWorkerFunction · 0.76