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@byzantine-lab.io>2019-06-12 17:23:39 +0800
commit29cb2039698ec0dd7cbb0a45693d3967f24aa84f (patch)
tree590d0293f4f56497292a2f2ec645f92bb98e3f4b /dex/handler.go
parent8f9b8dd7fe2ce248d780585436dac66b7bd1391a (diff)
downloadgo-tangerine-29cb2039698ec0dd7cbb0a45693d3967f24aa84f.tar.gz
go-tangerine-29cb2039698ec0dd7cbb0a45693d3967f24aa84f.tar.zst
go-tangerine-29cb2039698ec0dd7cbb0a45693d3967f24aa84f.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):