diff options
author | Sonic <sonic@cobinhood.com> | 2018-10-17 14:10:52 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2018-12-19 20:54:27 +0800 |
commit | 218f6e00e4af70ccfc5c8823ab4d9da60cbdcfed (patch) | |
tree | adf4c607d5dcbeb05463659a67c976fcae991d74 /dex/handler.go | |
parent | 1ec830bc3bc756d0297f344007ac914b973cd175 (diff) | |
download | dexon-218f6e00e4af70ccfc5c8823ab4d9da60cbdcfed.tar dexon-218f6e00e4af70ccfc5c8823ab4d9da60cbdcfed.tar.gz dexon-218f6e00e4af70ccfc5c8823ab4d9da60cbdcfed.tar.bz2 dexon-218f6e00e4af70ccfc5c8823ab4d9da60cbdcfed.tar.lz dexon-218f6e00e4af70ccfc5c8823ab4d9da60cbdcfed.tar.xz dexon-218f6e00e4af70ccfc5c8823ab4d9da60cbdcfed.tar.zst dexon-218f6e00e4af70ccfc5c8823ab4d9da60cbdcfed.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): |