diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/agreement.go | 13 | ||||
-rw-r--r-- | core/consensus.go | 5 |
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: + } } } } |