diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-01-28 15:23:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-28 15:23:54 +0800 |
commit | 6907a35141f4ab9c5c0d8fc2cb31eaaf60f0c867 (patch) | |
tree | 619c9fb3bb3e8cbb9730c030913391475853a7f3 | |
parent | 29eeeb08cac1b203dca2075d2901779d12be85b7 (diff) | |
download | dexon-consensus-6907a35141f4ab9c5c0d8fc2cb31eaaf60f0c867.tar dexon-consensus-6907a35141f4ab9c5c0d8fc2cb31eaaf60f0c867.tar.gz dexon-consensus-6907a35141f4ab9c5c0d8fc2cb31eaaf60f0c867.tar.bz2 dexon-consensus-6907a35141f4ab9c5c0d8fc2cb31eaaf60f0c867.tar.lz dexon-consensus-6907a35141f4ab9c5c0d8fc2cb31eaaf60f0c867.tar.xz dexon-consensus-6907a35141f4ab9c5c0d8fc2cb31eaaf60f0c867.tar.zst dexon-consensus-6907a35141f4ab9c5c0d8fc2cb31eaaf60f0c867.zip |
core: BA3.1 (#437)
* core: BA 3.1
* core: fix test
-rw-r--r-- | core/agreement.go | 10 | ||||
-rw-r--r-- | core/agreement_test.go | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/core/agreement.go b/core/agreement.go index c08518a..c2ac711 100644 --- a/core/agreement.go +++ b/core/agreement.go @@ -172,7 +172,7 @@ func (a *agreement) restart( defer a.data.blocksLock.Unlock() a.data.votes = make(map[uint64][]map[types.NodeID]*types.Vote) a.data.votes[1] = newVoteListMap() - a.data.period = 1 + a.data.period = 2 a.data.blocks = make(map[types.NodeID]*types.Block) a.data.requiredVote = len(notarySet)/3*2 + 1 a.data.leader.restart(crs) @@ -266,7 +266,11 @@ func isStop(aID types.Position) bool { func (a *agreement) clocks() int { a.data.lock.RLock() defer a.data.lock.RUnlock() - scale := int(a.data.period) + scale := int(a.data.period) - 1 + if scale < 1 { + // just in case. + scale = 1 + } // 10 is a magic number derived from many years of experience. if scale > 10 { scale = 10 @@ -420,7 +424,7 @@ func (a *agreement) processVote(vote *types.Vote) error { a.data.recv.ProposeVote( types.NewVote(types.VoteFastCom, hash, vote.Period)) a.data.lockValue = hash - a.data.lockIter = math.MaxUint64 + a.data.lockIter = 1 a.hasVoteFast = true } } else { diff --git a/core/agreement_test.go b/core/agreement_test.go index 4dbbe6e..f49fd7d 100644 --- a/core/agreement_test.go +++ b/core/agreement_test.go @@ -208,7 +208,7 @@ func (s *AgreementTestSuite) TestSimpleConfirm() { s.Equal(types.VoteCom, vote.Type) s.Equal(blockHash, vote.BlockHash) s.Equal(blockHash, a.data.lockValue) - s.Equal(uint64(1), a.data.lockIter) + s.Equal(uint64(2), a.data.lockIter) for nID := range s.signers { v := s.copyVote(vote, nID) s.Require().NoError(a.processVote(v)) @@ -256,7 +256,7 @@ func (s *AgreementTestSuite) TestPartitionOnCommitVote() { s.Equal(types.VoteCom, vote.Type) s.Equal(blockHash, vote.BlockHash) s.Equal(blockHash, a.data.lockValue) - s.Equal(uint64(1), a.data.lockIter) + s.Equal(uint64(2), a.data.lockIter) // RepeateVoteState a.nextState() s.True(a.pullVotes()) |