Skip to content

Commit ac80ec5

Browse files
committed
miner: update root only when mining
1 parent e349fac commit ac80ec5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

miner/worker.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,12 @@ func (self *worker) commitNewWork() {
416416
delete(self.possibleUncles, hash)
417417
}
418418

419-
// commit state root after all state transitions.
420-
core.AccumulateRewards(self.current.state, header, uncles)
421-
current.state.Update()
422-
header.Root = current.state.Root()
419+
if atomic.LoadInt32(&self.mining) == 1 {
420+
// commit state root after all state transitions.
421+
core.AccumulateRewards(self.current.state, header, uncles)
422+
current.state.Update()
423+
header.Root = current.state.Root()
424+
}
423425

424426
// create the new block whose nonce will be mined.
425427
current.block = types.NewBlock(header, current.txs, uncles, current.receipts)

0 commit comments

Comments
 (0)