aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-11-13 13:59:38 +0800
committerGitHub <noreply@github.com>2018-11-13 13:59:38 +0800
commit4752fffa3546c2968b310811dbd30281b197032c (patch)
tree99ab4df80ed462258fe75929e9a7dc1e4ce6f9e0 /core
parent28fa70583e4bc70089c17d8b00c258ab71e467e9 (diff)
downloaddexon-consensus-4752fffa3546c2968b310811dbd30281b197032c.tar
dexon-consensus-4752fffa3546c2968b310811dbd30281b197032c.tar.gz
dexon-consensus-4752fffa3546c2968b310811dbd30281b197032c.tar.bz2
dexon-consensus-4752fffa3546c2968b310811dbd30281b197032c.tar.lz
dexon-consensus-4752fffa3546c2968b310811dbd30281b197032c.tar.xz
dexon-consensus-4752fffa3546c2968b310811dbd30281b197032c.tar.zst
dexon-consensus-4752fffa3546c2968b310811dbd30281b197032c.zip
core: Fix data race (#319)
Diffstat (limited to 'core')
-rw-r--r--core/compaction-chain.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/compaction-chain.go b/core/compaction-chain.go
index 8080a2c..94dd24c 100644
--- a/core/compaction-chain.go
+++ b/core/compaction-chain.go
@@ -255,6 +255,10 @@ func (cc *compactionChain) processBlockRandomnessResult(
rand *types.BlockRandomnessResult) error {
cc.lock.Lock()
defer cc.lock.Unlock()
+ // prevBlock is already delivered so it doesn't need to process randomness.
+ if rand.BlockHash == cc.prevBlock.Hash {
+ return nil
+ }
// TODO(jimmy-dexon): the result should not be discarded here. Blocks may
// be registered later.
if !cc.blockRegisteredNoLock(rand.BlockHash) {