diff options
author | Sonic <sonic@cobinhood.com> | 2018-10-17 14:10:52 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 71c6a58419e1b68b49b6c7d307acee305474d248 (patch) | |
tree | 6191bff0d72a669a259cb5221c1e832a507275df /dex/handler.go | |
parent | b091251b901091e106f3b92be7f32a83ce5af6da (diff) | |
download | dexon-71c6a58419e1b68b49b6c7d307acee305474d248.tar.gz dexon-71c6a58419e1b68b49b6c7d307acee305474d248.tar.zst dexon-71c6a58419e1b68b49b6c7d307acee305474d248.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.go | 33 |
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): |