aboutsummaryrefslogtreecommitdiffstats
path: root/core/agreement.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-01-10 18:01:10 +0800
committerGitHub <noreply@github.com>2019-01-10 18:01:10 +0800
commitfa25817354d5b7d40f5911004232392acfe7fe53 (patch)
tree6e9c68971d4e5fecbd126568ebdb7f1026935d93 /core/agreement.go
parent995e571375298923bf07d205237a664b03de3b57 (diff)
downloaddexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.gz
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.bz2
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.lz
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.xz
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.zst
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.zip
core: fix issues in consensus core (#415)
Diffstat (limited to 'core/agreement.go')
-rw-r--r--core/agreement.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/core/agreement.go b/core/agreement.go
index 11ed89a..f9cf546 100644
--- a/core/agreement.go
+++ b/core/agreement.go
@@ -281,16 +281,12 @@ func (a *agreement) leader() types.NodeID {
// nextState is called at the specific clock time.
func (a *agreement) nextState() (err error) {
- if func() bool {
- a.lock.RLock()
- defer a.lock.RUnlock()
- return a.hasOutput
- }() {
+ a.lock.Lock()
+ defer a.lock.Unlock()
+ if a.hasOutput {
a.state = newSleepState(a.data)
return
}
- a.lock.Lock()
- defer a.lock.Unlock()
a.state, err = a.state.nextState()
return
}