switch to gossip broadcast for topology updates
This commit is contained in:
1 parent
f4416bfadc
commit
f80410bf59
4 files changed
+8
-10
No files matched your search
@@ -269,6 +269,7 @@ func (c *GossipChannel) relayBroadcast(srcName PeerName, update GossipData) erro
|
||||
}
|
||||
|
||||
func (c *GossipChannel) sendBroadcast(srcName PeerName, update GossipData) {
|
||||
c.ourself.Router.Routes.EnsureRecalculated()
|
||||
nextHops := c.ourself.Router.Routes.BroadcastAll(srcName)
|
||||
if len(nextHops) == 0 {
|
||||
return
|
||||
|
||||
@@ -241,14 +241,7 @@ func (peer *LocalPeer) handleDeleteConnection(conn Connection) {
|
||||
|
||||
func (peer *LocalPeer) broadcastPeerUpdate(peers ...*Peer) {
|
||||
peer.Router.Routes.Recalculate()
|
||||
// TODO We should just be invoking TopologyGossip.GossipBroadcast
|
||||
// here, but route calculation is asynchronous and in this
|
||||
// particular case would likely result in the broadcast not
|
||||
// reaching all peers. So instead we slightly break the Gossip
|
||||
// abstraction (hence the cast) and send a regular update. This is
|
||||
// less efficient though since it will almost certainly reach
|
||||
// peers more than once.
|
||||
peer.Router.TopologyGossip.(*GossipChannel).Send(NewTopologyGossipData(peer.Router.Peers, append(peers, peer.Peer)...))
|
||||
peer.Router.TopologyGossip.GossipBroadcast(NewTopologyGossipData(peer.Router.Peers, append(peers, peer.Peer)...))
|
||||
}
|
||||
|
||||
func (peer *LocalPeer) checkConnectionLimit() error {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package router
|
||||
|
||||
const (
|
||||
Protocol = "weave"
|
||||
ProtocolVersion = 14
|
||||
ProtocolVersion = 15
|
||||
)
|
||||
|
||||
type ProtocolTag byte
|
||||
|
||||
+5
-1
@@ -378,7 +378,11 @@ func (router *Router) OnGossipUnicast(sender PeerName, msg []byte) error {
|
||||
}
|
||||
|
||||
func (router *Router) OnGossipBroadcast(update []byte) (GossipData, error) {
|
||||
return nil, fmt.Errorf("unexpected topology gossip broadcast: %v", update)
|
||||
origUpdate, _, err := router.applyTopologyUpdate(update)
|
||||
if err != nil || len(origUpdate) == 0 {
|
||||
return nil, err
|
||||
}
|
||||
return &TopologyGossipData{peers: router.Peers, update: origUpdate}, nil
|
||||
}
|
||||
|
||||
func (router *Router) Gossip() GossipData {
|
||||
|
||||
Reference in new issue
Block a user