diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-10-31 17:22:29 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:52 +0800 |
commit | 48cd626abe5169e87e6a7f264f4f6cfda71c8e1f (patch) | |
tree | 10449b08e9ab9348cbeeb6dcc8c2e7725cb207e4 /vendor | |
parent | 2e2bf34bc283647b206b870a01e8e2fb668c39fa (diff) | |
download | dexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.tar.gz dexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.tar.zst dexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.zip |
vendor: sync consensus core and fix conflic
Diffstat (limited to 'vendor')
5 files changed, 48 insertions, 44 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) diff --git a/vendor/vendor.json b/vendor/vendor.json index 5ceaf2838..a71805391 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -105,50 +105,50 @@ { "checksumSHA1": "IKOLx0ZjJoT9x9zO/bVAXWcNXs8=", "path": "github.com/dexon-foundation/dexon-consensus-core/common", - "revision": "d7262107807dad33a8fd6219718c977748de4313", - "revisionTime": "2018-10-31T04:51:54Z" + "revision": "0cb33171cae5c6f3b3980fc2fd74a8a09766eedb", + "revisionTime": "2018-10-31T09:20:24Z" }, { - "checksumSHA1": "sskLEXy7lUSdWbJPgU43UY+MIE0=", + "checksumSHA1": "v0U3x0U5VXJY6RzocsQgqD0qCdM=", "path": "github.com/dexon-foundation/dexon-consensus-core/core", - "revision": "d7262107807dad33a8fd6219718c977748de4313", - "revisionTime": "2018-10-31T04:51:54Z" + "revision": "0cb33171cae5c6f3b3980fc2fd74a8a09766eedb", + "revisionTime": "2018-10-31T09:20:24Z" }, { "checksumSHA1": "69/j3ROwzhdGPWKymJnGjaJ5QzY=", "path": "github.com/dexon-foundation/dexon-consensus-core/core/blockdb", - "revision": "d7262107807dad33a8fd6219718c977748de4313", - "revisionTime": "2018-10-31T04:51:54Z" + "revision": "0cb33171cae5c6f3b3980fc2fd74a8a09766eedb", + "revisionTime": "2018-10-31T09:20:24Z" }, { "checksumSHA1": "GXHmtn3UlUftllBXI+M8RBkilzY=", "path": "github.com/dexon-foundation/dexon-consensus-core/core/crypto", - "revision": "d7262107807dad33a8fd6219718c977748de4313", - "revisionTime": "2018-10-31T04:51:54Z" + "revision": "0cb33171cae5c6f3b3980fc2fd74a8a09766eedb", + "revisionTime": "2018-10-31T09:20:24Z" }, { "checksumSHA1": "sh19Kk6G7esEcBPC2QsaFF3V/Ds=", "path": "github.com/dexon-foundation/dexon-consensus-core/core/crypto/dkg", - "revision": "d7262107807dad33a8fd6219718c977748de4313", - "revisionTime": "2018-10-31T04:51:54Z" + "revision": "0cb33171cae5c6f3b3980fc2fd74a8a09766eedb", + "revisionTime": "2018-10-31T09:20:24Z" }, { "checksumSHA1": "priVCcv7H4LTooiN/1EUu8qFiSs=", "path": "github.com/dexon-foundation/dexon-consensus-core/core/crypto/ecdsa", - "revision": "d7262107807dad33a8fd6219718c977748de4313", - "revisionTime": "2018-10-31T04:51:54Z" + "revision": "0cb33171cae5c6f3b3980fc2fd74a8a09766eedb", + "revisionTime": "2018-10-31T09:20:24Z" }, { "checksumSHA1": "ZWmUF+3/pobzITsGZSOOtvK1nvs=", "path": "github.com/dexon-foundation/dexon-consensus-core/core/types", - "revision": "d7262107807dad33a8fd6219718c977748de4313", - "revisionTime": "2018-10-31T04:51:54Z" + "revision": "0cb33171cae5c6f3b3980fc2fd74a8a09766eedb", + "revisionTime": "2018-10-31T09:20:24Z" }, { "checksumSHA1": "ZOjAnqYE7HayNBTsMIgRQPLxndI=", "path": "github.com/dexon-foundation/dexon-consensus-core/core/types/dkg", - "revision": "d7262107807dad33a8fd6219718c977748de4313", - "revisionTime": "2018-10-31T04:51:54Z" + "revision": "0cb33171cae5c6f3b3980fc2fd74a8a09766eedb", + "revisionTime": "2018-10-31T09:20:24Z" }, { "checksumSHA1": "TAkwduKZqLyimyTPPWIllZWYFuE=", |