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.
This commit is contained in:
1 parent
7e15eabe65
commit
cbb2ad018d
1 file changed
+3
-3
+3
-3
@@ -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})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user