From ca8cb65b73b5bdb6a30b6a45304b3c45acc66bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 9 Jun 2015 15:30:46 +0300 Subject: [PATCH] core: fix data race accessing ChainManager.currentBlock --- core/chain_manager.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/chain_manager.go b/core/chain_manager.go index 2333368deb..2ba81550ef 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() }