aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-11-05 10:31:43 +0800
committerGitHub <noreply@github.com>2018-11-05 10:31:43 +0800
commit740c5775e4fe97eaacd8c8bfe8f39076018565ab (patch)
treec44e32992e00259bbec828dd96cddbe4590de9e7 /core
parentc6db0b2491c8869b37ec6c8bc1a1264a1e4bfe7f (diff)
downloaddexon-consensus-740c5775e4fe97eaacd8c8bfe8f39076018565ab.tar
dexon-consensus-740c5775e4fe97eaacd8c8bfe8f39076018565ab.tar.gz
dexon-consensus-740c5775e4fe97eaacd8c8bfe8f39076018565ab.tar.bz2
dexon-consensus-740c5775e4fe97eaacd8c8bfe8f39076018565ab.tar.lz
dexon-consensus-740c5775e4fe97eaacd8c8bfe8f39076018565ab.tar.xz
dexon-consensus-740c5775e4fe97eaacd8c8bfe8f39076018565ab.tar.zst
dexon-consensus-740c5775e4fe97eaacd8c8bfe8f39076018565ab.zip
core: Fix BA stuffs (#293)
Diffstat (limited to 'core')
-rw-r--r--core/agreement.go13
-rw-r--r--core/consensus.go5
2 files changed, 15 insertions, 3 deletions
diff --git a/core/agreement.go b/core/agreement.go
index b922cae..80c0e2c 100644
--- a/core/agreement.go
+++ b/core/agreement.go
@@ -140,9 +140,15 @@ func newAgreement(
func (a *agreement) restart(
notarySet map[types.NodeID]struct{}, aID types.Position, crs common.Hash) {
- func() {
+ if !func() bool {
a.lock.Lock()
defer a.lock.Unlock()
+ if !isStop(aID) {
+ oldAID := a.agreementID()
+ if !isStop(oldAID) && !aID.Newer(&oldAID) {
+ return false
+ }
+ }
a.data.lock.Lock()
defer a.data.lock.Unlock()
a.data.blocksLock.Lock()
@@ -161,7 +167,10 @@ func (a *agreement) restart(
a.notarySet = notarySet
a.candidateBlock = make(map[common.Hash]*types.Block)
a.aID.Store(aID)
- }()
+ return true
+ }() {
+ return
+ }
if isStop(aID) {
return
diff --git a/core/consensus.go b/core/consensus.go
index c781de1..5c9823b 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -430,7 +430,10 @@ func (con *Consensus) Run(initBlock *types.Block) {
for {
<-con.tickerObj.Tick()
for _, tick := range ticks {
- go func(tick chan struct{}) { tick <- struct{}{} }(tick)
+ select {
+ case tick <- struct{}{}:
+ default:
+ }
}
}
}