MCPcopy Create free account
hub / github.com/CPChain/chain / wait

Method wait

miner/engine.go:312–338  ·  view source on GitHub ↗

wait handles mined blocks.

()

Source from the content-addressed store, hash-verified

310
311// wait handles mined blocks.
312func (e *engine) wait() {
313 for {
314 select {
315 case result := <-e.recv:
316 atomic.AddInt32(&e.atWork, -1)
317
318 if result == nil {
319 continue
320 }
321 block := result.Block
322
323 if block.NumberU64() <= e.lastBlock {
324 // ignore the same height new block or old block
325 log.Warn("detected duplicate blocks with same block number", "number", block.NumberU64())
326 continue
327 }
328 e.lastBlock = block.NumberU64()
329
330 // broadcast the block and announce chain insertion event
331 _ = e.mux.Post(core.NewMinedBlockEvent{Block: block})
332
333 case <-e.quitCh:
334 log.Info("goroutine wait() quit")
335 return
336 }
337 }
338}
339
340// push sends a new work task to currently live miner workers.
341func (e *engine) push(work *Work) {

Callers 1

startMethod · 0.95

Calls 3

NumberU64Method · 0.80
WarnMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected