Browse Source

miner: fix state locking while writing to chain (issue #16933) (#17173)

ledgerwatch 7 years ago
parent
commit
2fbc454355
1 changed files with 2 additions and 0 deletions
  1. 2 0
      miner/worker.go

+ 2 - 0
miner/worker.go

@@ -316,7 +316,9 @@ func (self *worker) wait() {
 			for _, log := range work.state.Logs() {
 				log.BlockHash = block.Hash()
 			}
+			self.currentMu.Lock()
 			stat, err := self.chain.WriteBlockWithState(block, work.receipts, work.state)
+			self.currentMu.Unlock()
 			if err != nil {
 				log.Error("Failed writing block to chain", "err", err)
 				continue