aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-09 20:30:46 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-09 20:30:46 +0800
commitca8cb65b73b5bdb6a30b6a45304b3c45acc66bcc (patch)
treed050f9140aae8ac7d3c28b3abc562717b74a9587 /core
parent07baf66200c74a97b440a199dce7321b23aea4cd (diff)
downloaddexon-ca8cb65b73b5bdb6a30b6a45304b3c45acc66bcc.tar
dexon-ca8cb65b73b5bdb6a30b6a45304b3c45acc66bcc.tar.gz
dexon-ca8cb65b73b5bdb6a30b6a45304b3c45acc66bcc.tar.bz2
dexon-ca8cb65b73b5bdb6a30b6a45304b3c45acc66bcc.tar.lz
dexon-ca8cb65b73b5bdb6a30b6a45304b3c45acc66bcc.tar.xz
dexon-ca8cb65b73b5bdb6a30b6a45304b3c45acc66bcc.tar.zst
dexon-ca8cb65b73b5bdb6a30b6a45304b3c45acc66bcc.zip
core: fix data race accessing ChainManager.currentBlock
Diffstat (limited to 'core')
-rw-r--r--core/chain_manager.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 2333368de..2ba81550e 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -379,8 +379,11 @@ func (self *ChainManager) ExportN(w io.Writer, first uint64, last uint64) error
func (bc *ChainManager) insert(block *types.Block) {
key := append(blockNumPre, block.Number().Bytes()...)
bc.blockDb.Put(key, block.Hash().Bytes())
-
bc.blockDb.Put([]byte("LastBlock"), block.Hash().Bytes())
+
+ bc.mu.Lock()
+ defer bc.mu.Unlock()
+
bc.currentBlock = block
bc.lastBlockHash = block.Hash()
}