aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-31 17:22:29 +0800
committerWei-Ning Huang <w@dexon.org>2018-12-19 20:54:27 +0800
commit26b7d6403b713717d46fef1fa2bed273722a4ce8 (patch)
tree3acd53b240a60a985943c72a452374c240a904e3 /vendor/github.com/dexon-foundation
parentee41b31d622c2f808425ebee8ca461ad34fa405c (diff)
downloaddexon-26b7d6403b713717d46fef1fa2bed273722a4ce8.tar
dexon-26b7d6403b713717d46fef1fa2bed273722a4ce8.tar.gz
dexon-26b7d6403b713717d46fef1fa2bed273722a4ce8.tar.bz2
dexon-26b7d6403b713717d46fef1fa2bed273722a4ce8.tar.lz
dexon-26b7d6403b713717d46fef1fa2bed273722a4ce8.tar.xz
dexon-26b7d6403b713717d46fef1fa2bed273722a4ce8.tar.zst
dexon-26b7d6403b713717d46fef1fa2bed273722a4ce8.zip
vendor: sync consensus core and fix conflic
Diffstat (limited to 'vendor/github.com/dexon-foundation')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement-state.go44
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus-core/core/agreement.go5
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus-core/core/consensus.go6
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus-core/core/interfaces.go3
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)