diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-02-01 13:29:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-01 13:29:37 +0800 |
commit | b29c4d5ab2313ecbc7822bf7c6d0374a44bf4a04 (patch) | |
tree | 38a4c5a37485625be1b2c94e31d77ba5402f290e | |
parent | 6907a35141f4ab9c5c0d8fc2cb31eaaf60f0c867 (diff) | |
download | dexon-consensus-b29c4d5ab2313ecbc7822bf7c6d0374a44bf4a04.tar dexon-consensus-b29c4d5ab2313ecbc7822bf7c6d0374a44bf4a04.tar.gz dexon-consensus-b29c4d5ab2313ecbc7822bf7c6d0374a44bf4a04.tar.bz2 dexon-consensus-b29c4d5ab2313ecbc7822bf7c6d0374a44bf4a04.tar.lz dexon-consensus-b29c4d5ab2313ecbc7822bf7c6d0374a44bf4a04.tar.xz dexon-consensus-b29c4d5ab2313ecbc7822bf7c6d0374a44bf4a04.tar.zst dexon-consensus-b29c4d5ab2313ecbc7822bf7c6d0374a44bf4a04.zip |
core: fix lock in agreement (#439)
* core: fix lock in agreement
* fix
* terminate leader go routine if agreement already restarted to new position
-rw-r--r-- | core/agreement.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/agreement.go b/core/agreement.go index c2ac711..39cd368 100644 --- a/core/agreement.go +++ b/core/agreement.go @@ -562,17 +562,22 @@ func (a *agreement) processBlock(block *types.Block) error { block.ProposerID == a.leader() { go func() { for func() bool { + if aID != a.agreementID() { + return false + } a.lock.RLock() defer a.lock.RUnlock() if a.state.state() != stateFast && a.state.state() != stateFastVote { return false } + a.data.lock.RLock() + defer a.data.lock.RUnlock() + a.data.blocksLock.Lock() + defer a.data.blocksLock.Unlock() block, exist := a.data.blocks[a.leader()] if !exist { return true } - a.data.lock.RLock() - defer a.data.lock.RUnlock() ok, err := a.data.leader.validLeader(block) if err != nil { fmt.Println("Error checking validLeader for Fast BA", |