miner: not call commitNewWork if it's a side block

This commit is contained in:
mark.lin 2018-05-18 13:43:30 +08:00
parent 6cf0ab38bd
commit 950073646e

View file

@ -290,7 +290,6 @@ func (self *worker) update() {
func (self *worker) wait() { func (self *worker) wait() {
for { for {
mustCommitNewWork := true
for result := range self.recv { for result := range self.recv {
atomic.AddInt32(&self.atWork, -1) atomic.AddInt32(&self.atWork, -1)
@ -315,11 +314,6 @@ func (self *worker) wait() {
log.Error("Failed writing block to chain", "err", err) log.Error("Failed writing block to chain", "err", err)
continue continue
} }
// check if canon block and write transactions
if stat == core.CanonStatTy {
// implicit by posting ChainHeadEvent
mustCommitNewWork = false
}
// Broadcast the block and announce chain insertion event // Broadcast the block and announce chain insertion event
self.mux.Post(core.NewMinedBlockEvent{Block: block}) self.mux.Post(core.NewMinedBlockEvent{Block: block})
var ( var (
@ -334,10 +328,6 @@ func (self *worker) wait() {
// Insert the block into the set of pending ones to wait for confirmations // Insert the block into the set of pending ones to wait for confirmations
self.unconfirmed.Insert(block.NumberU64(), block.Hash()) self.unconfirmed.Insert(block.NumberU64(), block.Hash())
if mustCommitNewWork {
self.commitNewWork()
}
} }
} }
} }