aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-31 17:22:29 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:52 +0800
commit48cd626abe5169e87e6a7f264f4f6cfda71c8e1f (patch)
tree10449b08e9ab9348cbeeb6dcc8c2e7725cb207e4
parent2e2bf34bc283647b206b870a01e8e2fb668c39fa (diff)
downloaddexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.tar
dexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.tar.gz
dexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.tar.bz2
dexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.tar.lz
dexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.tar.xz
dexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.tar.zst
dexon-48cd626abe5169e87e6a7f264f4f6cfda71c8e1f.zip
vendor: sync consensus core and fix conflic
-rw-r--r--dex/network.go21
-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
-rw-r--r--vendor/vendor.json34
6 files changed, 69 insertions, 44 deletions
diff --git a/dex/network.go b/dex/network.go
index cb22340f3..58d6fd855 100644
--- a/dex/network.go
+++ b/dex/network.go
@@ -1,3 +1,20 @@
+// Copyright 2018 The dexon-consensus-core Authors
+// This file is part of the dexon-consensus-core library.
+//
+// The dexon-consensus-core library is free software: you can redistribute it
+// and/or modify it under the terms of the GNU Lesser General Public License as
+// published by the Free Software Foundation, either version 3 of the License,
+// or (at your option) any later version.
+//
+// The dexon-consensus-core library is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+// General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the dexon-consensus-core library. If not, see
+// <http://www.gnu.org/licenses/>.
+
package dex
import (
@@ -19,6 +36,10 @@ func NewDexconNetwork(pm *ProtocolManager) *DexconNetwork {
func (n *DexconNetwork) PullBlocks(hashes coreCommon.Hashes) {
}
+// PullVotes tries to pull votes from the DEXON network.
+func (n *DexconNetwork) PullVotes(pos types.Position) {
+}
+
// BroadcastVote broadcasts vote to all nodes in DEXON network.
func (n *DexconNetwork) BroadcastVote(vote *types.Vote) {
n.pm.BroadcastVote(vote)
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=",