aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-10 02:13:21 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-10 02:13:21 +0800
commitd652a58ada207fa9a372f2fa594d5a151ed44a4f (patch)
tree610d8912204587a3afe5aa2e2c366424be7c121a /core
parentfecf2141750fe61640870672987023fe7213901a (diff)
downloadgo-tangerine-d652a58ada207fa9a372f2fa594d5a151ed44a4f.tar
go-tangerine-d652a58ada207fa9a372f2fa594d5a151ed44a4f.tar.gz
go-tangerine-d652a58ada207fa9a372f2fa594d5a151ed44a4f.tar.bz2
go-tangerine-d652a58ada207fa9a372f2fa594d5a151ed44a4f.tar.lz
go-tangerine-d652a58ada207fa9a372f2fa594d5a151ed44a4f.tar.xz
go-tangerine-d652a58ada207fa9a372f2fa594d5a151ed44a4f.tar.zst
go-tangerine-d652a58ada207fa9a372f2fa594d5a151ed44a4f.zip
core: fix a race condition accessing the gas limit
Diffstat (limited to 'core')
-rw-r--r--core/chain_manager.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 82fdbb1f1..6897c453c 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -179,7 +179,9 @@ func (self *ChainManager) Td() *big.Int {
}
func (self *ChainManager) GasLimit() *big.Int {
- // return self.currentGasLimit
+ self.mu.RLock()
+ defer self.mu.RUnlock()
+
return self.currentBlock.GasLimit()
}
@@ -376,8 +378,8 @@ func (self *ChainManager) ExportN(w io.Writer, first uint64, last uint64) error
return nil
}
-// insert appends injects a block into the current chain block chain. Note, this
-// function assumes that the `mu` mutex is held!
+// insert injects a block into the current chain block chain. Note, this function
+// assumes that the `mu` mutex is held!
func (bc *ChainManager) insert(block *types.Block) {
key := append(blockNumPre, block.Number().Bytes()...)
bc.blockDb.Put(key, block.Hash().Bytes())