aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-29 11:24:53 +0800
committerGitHub <noreply@github.com>2018-10-29 11:24:53 +0800
commit843f43bf245f0398fc581e885943661967ca1bc0 (patch)
tree9bb02b341c2d2282463b3532f12e89e4632150aa /core
parentadcdaa20165ec299d2782f032e112b050a15c45f (diff)
downloadtangerine-consensus-843f43bf245f0398fc581e885943661967ca1bc0.tar
tangerine-consensus-843f43bf245f0398fc581e885943661967ca1bc0.tar.gz
tangerine-consensus-843f43bf245f0398fc581e885943661967ca1bc0.tar.bz2
tangerine-consensus-843f43bf245f0398fc581e885943661967ca1bc0.tar.lz
tangerine-consensus-843f43bf245f0398fc581e885943661967ca1bc0.tar.xz
tangerine-consensus-843f43bf245f0398fc581e885943661967ca1bc0.tar.zst
tangerine-consensus-843f43bf245f0398fc581e885943661967ca1bc0.zip
core: Do not process vote/block in agreement if it has stopped (#269)
Diffstat (limited to 'core')
-rw-r--r--core/agreement.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/core/agreement.go b/core/agreement.go
index cab896c..8c2218b 100644
--- a/core/agreement.go
+++ b/core/agreement.go
@@ -160,6 +160,10 @@ func (a *agreement) restart(
a.aID = *aID.Clone()
}()
+ if isStop(aID) {
+ return
+ }
+
expireTime := time.Now().Add(-10 * time.Second)
replayBlock := make([]*types.Block, 0)
func() {
@@ -210,6 +214,10 @@ func (a *agreement) stop() {
})
}
+func isStop(aID types.Position) bool {
+ return aID.ChainID == math.MaxUint32
+}
+
// clocks returns how many time this state is required.
func (a *agreement) clocks() int {
return a.state.clocks()
@@ -279,8 +287,11 @@ func (a *agreement) processVote(vote *types.Vote) error {
}
aID := a.agreementID()
if vote.Position != aID {
- if aID.Newer(&vote.Position) {
- return nil
+ // Agreement module has stopped.
+ if !isStop(aID) {
+ if aID.Newer(&vote.Position) {
+ return nil
+ }
}
a.lock.Lock()
defer a.lock.Unlock()
@@ -383,8 +394,11 @@ func (a *agreement) processBlock(block *types.Block) error {
aID := a.agreementID()
if block.Position != aID {
- if aID.Newer(&block.Position) {
- return nil
+ // Agreement module has stopped.
+ if !isStop(aID) {
+ if aID.Newer(&block.Position) {
+ return nil
+ }
}
a.pendingBlock = append(a.pendingBlock, pendingBlock{
block: block,