diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-10-31 17:22:29 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:17 +0800 |
commit | 26907d464cf2c16e15916c298f7b12e3e8b61be0 (patch) | |
tree | 446e497eb853761bf18a812179dca6df37c6e9c8 /vendor/github.com | |
parent | 79b3816f9ac27e151d2b9d6a76790fac8787e978 (diff) | |
download | go-tangerine-26907d464cf2c16e15916c298f7b12e3e8b61be0.tar go-tangerine-26907d464cf2c16e15916c298f7b12e3e8b61be0.tar.gz go-tangerine-26907d464cf2c16e15916c298f7b12e3e8b61be0.tar.bz2 go-tangerine-26907d464cf2c16e15916c298f7b12e3e8b61be0.tar.lz go-tangerine-26907d464cf2c16e15916c298f7b12e3e8b61be0.tar.xz go-tangerine-26907d464cf2c16e15916c298f7b12e3e8b61be0.tar.zst go-tangerine-26907d464cf2c16e15916c298f7b12e3e8b61be0.zip |
vendor: sync consensus core and fix conflic
Diffstat (limited to 'vendor/github.com')
4 files changed, 31 insertions, 27 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement-state.go b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement-state.go index 77195ace1..426b0629c 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement-state.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement-state.go @@ -39,7 +39,7 @@ const ( statePreCommit stateCommit stateForward - stateRepeatVote + statePullVote ) var nullBlockHash = common.Hash{} @@ -127,54 +127,44 @@ func (s *commitState) nextState() (agreementState, error) { } else { hash = skipBlockHash } - vote := &types.Vote{ + s.a.recv.ProposeVote(&types.Vote{ Type: types.VoteCom, BlockHash: hash, Period: s.a.period, - } - s.a.recv.ProposeVote(vote) - return newForwardState(s.a, vote), nil + }) + return newForwardState(s.a), nil } // ----- ForwardState ----- type forwardState struct { - a *agreementData - vote *types.Vote + a *agreementData } -func newForwardState(a *agreementData, vote *types.Vote) *forwardState { - return &forwardState{ - a: a, - vote: vote, - } +func newForwardState(a *agreementData) *forwardState { + return &forwardState{a: a} } func (s *forwardState) state() agreementStateType { return stateForward } func (s *forwardState) clocks() int { return 4 } func (s *forwardState) nextState() (agreementState, error) { - return newRepeatVoteState(s.a, s.vote), nil + return newPullVoteState(s.a), nil } -// ----- RepeatVoteState ----- -// repeateVoteState is a special state to ensure the assumption in the consensus +// ----- PullVoteState ----- +// pullVoteState is a special state to ensure the assumption in the consensus // algorithm that every vote will eventually arrive for all nodes. -type repeatVoteState struct { - a *agreementData - vote *types.Vote +type pullVoteState struct { + a *agreementData } -func newRepeatVoteState(a *agreementData, vote *types.Vote) *repeatVoteState { - return &repeatVoteState{ - a: a, - vote: vote, - } +func newPullVoteState(a *agreementData) *pullVoteState { + return &pullVoteState{a: a} } -func (s *repeatVoteState) state() agreementStateType { return stateRepeatVote } -func (s *repeatVoteState) clocks() int { return 4 } +func (s *pullVoteState) state() agreementStateType { return statePullVote } +func (s *pullVoteState) clocks() int { return 4 } -func (s *repeatVoteState) nextState() (agreementState, error) { - s.a.recv.ProposeVote(s.vote) +func (s *pullVoteState) nextState() (agreementState, error) { return s, nil } diff --git a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement.go b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement.go index 8c2218be0..3162b2e57 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement.go @@ -223,6 +223,11 @@ func (a *agreement) clocks() int { return a.state.clocks() } +// pullVotes returns if current agreement requires more votes to continue. +func (a *agreement) pullVotes() bool { + return a.state.state() == statePullVote +} + // agreementID returns the current agreementID. func (a *agreement) agreementID() types.Position { a.lock.RLock() diff --git a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go index 394ae36a1..15ecf67c7 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go @@ -471,6 +471,12 @@ BALoop: agreement.restart(nIDs, nextPos) default: } + if agreement.pullVotes() { + pos := agreement.agreementID() + con.logger.Debug("Calling Network.PullVotes for syncing votes", + "position", pos) + con.network.PullVotes(pos) + } err := agreement.nextState() if err != nil { con.logger.Error("Failed to proceed to next state", diff --git a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/interfaces.go b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/interfaces.go index 4f6ad45a2..d6c1baf3e 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus-core/core/interfaces.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus-core/core/interfaces.go @@ -62,6 +62,9 @@ type Network interface { // PullBlocks tries to pull blocks from the DEXON network. PullBlocks(hashes common.Hashes) + // PullVotes tries to pull votes from the DEXON network. + PullVotes(position types.Position) + // BroadcastVote broadcasts vote to all nodes in DEXON network. BroadcastVote(vote *types.Vote) |