Start is the main event loop.
()
| 300 | |
| 301 | // Start is the main event loop. |
| 302 | func (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 |
| 334 | func (worker *txPoolWorker) stop() { |