()
| 253 | } |
| 254 | |
| 255 | func (e *Exchange) process() { |
| 256 | if e.newBlockHeaderCh == nil || e.wg == nil { |
| 257 | return |
| 258 | } |
| 259 | |
| 260 | defer e.wg.Done() |
| 261 | processTick := time.NewTicker(10 * conf.GConf.BPPeriod) |
| 262 | defer processTick.Stop() |
| 263 | |
| 264 | for { |
| 265 | select { |
| 266 | case b := <-e.newBlockCh: |
| 267 | _ = e.processBlock(b) |
| 268 | case blockHead := <-e.newBlockHeaderCh: |
| 269 | e.wg.Add(1) |
| 270 | go e.fetchBlock(blockHead) |
| 271 | case <-e.processCtx.Done(): |
| 272 | return |
| 273 | case <-processTick.C: |
| 274 | // load tx and process |
| 275 | e.processPendingTxs() |
| 276 | default: |
| 277 | // update transferring tx state |
| 278 | e.updateTransferringTxState() |
| 279 | // update transferring tx state |
| 280 | e.expireStaleTx() |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | } |
| 285 | |
| 286 | func (e *Exchange) processBlock(b *types.Block) (err error) { |
| 287 | // set back to queue |
no test coverage detected