Skip to content

Commit d652a58

Browse files
committed
core: fix a race condition accessing the gas limit
1 parent fecf214 commit d652a58

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/chain_manager.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ func (self *ChainManager) Td() *big.Int {
179179
}
180180

181181
func (self *ChainManager) GasLimit() *big.Int {
182-
// return self.currentGasLimit
182+
self.mu.RLock()
183+
defer self.mu.RUnlock()
184+
183185
return self.currentBlock.GasLimit()
184186
}
185187

@@ -376,8 +378,8 @@ func (self *ChainManager) ExportN(w io.Writer, first uint64, last uint64) error
376378
return nil
377379
}
378380

379-
// insert appends injects a block into the current chain block chain. Note, this
380-
// function assumes that the `mu` mutex is held!
381+
// insert injects a block into the current chain block chain. Note, this function
382+
// assumes that the `mu` mutex is held!
381383
func (bc *ChainManager) insert(block *types.Block) {
382384
key := append(blockNumPre, block.Number().Bytes()...)
383385
bc.blockDb.Put(key, block.Hash().Bytes())

0 commit comments

Comments
 (0)