From cbb2ad018da70c52578cc694f65379c83db01114 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Tue, 1 Dec 2015 13:10:06 +0000 Subject: [PATCH] don't broadcast-gossip other peer when adding a connection This is more efficient since broadcasting about other peers is strictly redundant. Any change to the peers will be broadcast by those peers anyway. And SendAllGossipDown takes care of informing new peers about others on first connect, and periodic gossip take care of missed broadcasts. The only reason we did broadcast about the remote peer is to reduce the liklihood of UnknownPeerError and the associated throwing away of gossip. This was always a bit of kludge, and is no longer necessary since UnknownPeerError is gone. Now peers only ever broadcast information about themselves. Which, unlike information about other peers, is always authorative and most up-to-date. Which is nice. --- mesh/local_peer.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mesh/local_peer.go b/mesh/local_peer.go index 72262e59..d26ad5a3 100644 --- a/mesh/local_peer.go +++ b/mesh/local_peer.go @@ -157,7 +157,7 @@ func (peer *LocalPeer) handleAddConnection(conn Connection) error { } peer.router.Routes.Recalculate() - peer.broadcastPeerUpdate(conn.Remote()) + peer.broadcastPeerUpdate() return nil } @@ -199,13 +199,13 @@ func (peer *LocalPeer) handleDeleteConnection(conn Connection) { // helpers -func (peer *LocalPeer) broadcastPeerUpdate(peers ...*Peer) { +func (peer *LocalPeer) broadcastPeerUpdate() { // Some tests run without a router. This should be fixed so // that the relevant part of Router can be easily run in the // context of a test, but that will involve significant // reworking of tests. if peer.router != nil { - peer.router.BroadcastTopologyUpdate(append(peers, peer.Peer)) + peer.router.BroadcastTopologyUpdate([]*Peer{peer.Peer}) } }