diff --git a/router/peer.go b/router/peer.go index 5fcf277a..cbfa9f59 100644 --- a/router/peer.go +++ b/router/peer.go @@ -73,7 +73,6 @@ func (peer *Peer) Routes(stopAt *Peer, establishedAndSymmetric bool) (bool, map[ if curPeer == stopAt { return true, routes } - curName := curPeer.Name for remoteName, conn := range curPeer.connections { if establishedAndSymmetric && !conn.Established() { continue @@ -81,9 +80,8 @@ func (peer *Peer) Routes(stopAt *Peer, establishedAndSymmetric bool) (bool, map[ if _, found := routes[remoteName]; found { continue } - remote := conn.Remote() - if remoteConn, found := remote.connections[curName]; !establishedAndSymmetric || (found && remoteConn.Established()) { - nextWorklist = append(nextWorklist, remote) + if remoteConn, found := conn.Remote().connections[curPeer.Name]; !establishedAndSymmetric || (found && remoteConn.Established()) { + nextWorklist = append(nextWorklist, conn.Remote()) // We now know how to get to remoteName: the same // way we get to curPeer. Except, if curPeer is // the starting peer in which case we know we can @@ -91,7 +89,7 @@ func (peer *Peer) Routes(stopAt *Peer, establishedAndSymmetric bool) (bool, map[ if curPeer == peer { routes[remoteName] = remoteName } else { - routes[remoteName] = routes[curName] + routes[remoteName] = routes[curPeer.Name] } } } diff --git a/router/routes.go b/router/routes.go index f7c7c746..e464c8e2 100644 --- a/router/routes.go +++ b/router/routes.go @@ -225,11 +225,10 @@ func (routes *Routes) calculateBroadcast(establishedAndSymmetric bool) map[PeerN // This is rather similar to the inner loop on // peer.Routes(...); the main difference is in the // locking. - for _, conn := range routes.ourself.connections { + for remoteName, conn := range routes.ourself.connections { if establishedAndSymmetric && !conn.Established() { continue } - remoteName := conn.Remote().Name if _, found := reached[remoteName]; found { continue }