Merge pull request #453 from rade/452_only_broadcast_on_established

LGTM.  Fixes #452 - those messages go away entirely in my tests.
This commit is contained in:
Bryan Boreham committed 2015-03-12 11:27:34 +00:00
commit cce6175a5c
1 file changed
+7 -1
+7 -1
View File
@@ -137,11 +137,17 @@ func (routes *Routes) calculateBroadcast() map[PeerName][]PeerName {
routes.peers.ForEach(func(name PeerName, peer *Peer) {
hops := []PeerName{}
if found, reached := peer.Routes(ourself, true); found {
// This is rather similar to the inner loop on
// peer.Routes(...); the main difference is in the
// locking.
ourself.ForEachConnection(func(remoteName PeerName, conn Connection) {
if !conn.Established() {
return
}
if _, found := reached[remoteName]; found {
return
}
if _, found := conn.Remote().ConnectionTo(ourself.Name); found {
if remoteConn, found := conn.Remote().ConnectionTo(ourself.Name); found && remoteConn.Established() {
hops = append(hops, remoteName)
}
})