From e1b6511d9d2e4ebd4a3df6e580861e788989ba60 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Tue, 31 Jul 2018 08:22:33 +0100 Subject: [PATCH] miner: fix state locking while writing to chain (issue #16933) (#17173) --- miner/worker.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/miner/worker.go b/miner/worker.go index ff48ecabc3dd..ee7506d70f32 100644 --- a/miner/worker.go +++ b/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