aboutsummaryrefslogtreecommitdiffstats
path: root/dex/handler.go
diff options
context:
space:
mode:
authorSonic <sonic@cobinhood.com>2018-10-17 14:10:52 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:50 +0800
commitcd094147171175d49c82dd9783ce880f6307e175 (patch)
treeab395f554f8b69495564288197b10aa2f2379658 /dex/handler.go
parent08c1014238f45821f6e7e29e9fecfeb203751fd5 (diff)
downloaddexon-cd094147171175d49c82dd9783ce880f6307e175.tar
dexon-cd094147171175d49c82dd9783ce880f6307e175.tar.gz
dexon-cd094147171175d49c82dd9783ce880f6307e175.tar.bz2
dexon-cd094147171175d49c82dd9783ce880f6307e175.tar.lz
dexon-cd094147171175d49c82dd9783ce880f6307e175.tar.xz
dexon-cd094147171175d49c82dd9783ce880f6307e175.tar.zst
dexon-cd094147171175d49c82dd9783ce880f6307e175.zip
dex: let notary nodes connect to some dkg nodes
BuildConnection builds notary and dkg connections together
Diffstat (limited to 'dex/handler.go')
-rw-r--r--dex/handler.go33
1 files changed, 17 insertions, 16 deletions
diff --git a/dex/handler.go b/dex/handler.go
index b605c907a..cdadd2874 100644
--- a/dex/handler.go
+++ b/dex/handler.go
@@ -824,8 +824,16 @@ func (pm *ProtocolManager) BroadcastMetas(metas []*NodeMeta) {
}
func (pm *ProtocolManager) BroadcastVote(vote *coreTypes.Vote) {
- for _, peer := range pm.peers.allPeers() {
- peer.AsyncSendVote(vote)
+ label := peerLabel{
+ set: notaryset,
+ chainID: vote.Position.ChainID,
+ round: vote.Position.Round,
+ }
+ h := rlpHash(vote)
+ for _, peer := range pm.peers.PeersWithLabel(label) {
+ if !peer.knownVotes.Contains(h) {
+ peer.AsyncSendVote(vote)
+ }
}
}
@@ -923,11 +931,9 @@ func (pm *ProtocolManager) peerSetLoop() {
round := pm.gov.LenCRS() - 1
log.Trace("first len crs", "len", round+1, "round", round)
if round >= 1 {
- pm.peers.BuildNotaryConn(round - 1)
- pm.peers.BuildDKGConn(round - 1)
+ pm.peers.BuildConnection(round - 1)
}
- pm.peers.BuildNotaryConn(round)
- pm.peers.BuildDKGConn(round)
+ pm.peers.BuildConnection(round)
for {
select {
@@ -938,21 +944,16 @@ func (pm *ProtocolManager) peerSetLoop() {
break
}
if newRound == round+1 {
- pm.peers.BuildNotaryConn(newRound)
- pm.peers.BuildDKGConn(newRound)
- pm.peers.ForgetNotaryConn(round - 1)
- pm.peers.ForgetDKGConn(round - 1)
+ pm.peers.BuildConnection(newRound)
+ pm.peers.ForgetConnection(round - 1)
} else {
// just forget all network connection and rebuild.
- pm.peers.ForgetNotaryConn(round)
- pm.peers.ForgetDKGConn(round)
+ pm.peers.ForgetConnection(round)
if newRound >= 1 {
- pm.peers.BuildNotaryConn(newRound - 1)
- pm.peers.BuildDKGConn(newRound - 1)
+ pm.peers.BuildConnection(newRound - 1)
}
- pm.peers.BuildNotaryConn(newRound)
- pm.peers.BuildDKGConn(newRound)
+ pm.peers.BuildConnection(newRound)
}
round = newRound
case <-time.After(5 * time.Second):