get rid of Router.NormalisePeerAddr

There was only one call site left and it always gets invoked with an
ip:port, so normalisation is a no-op.

Also remove mysterious comment.
This commit is contained in:
Matthias Radestock committed 2015-04-15 11:44:48 +01:00
1 parent 290d5443cc
commit 339f85cbcb
2 files changed
+2 -14

No files matched your search

+2 -4
View File
@@ -93,10 +93,8 @@ func (peer *LocalPeer) CreateConnection(peerAddr string, acceptNewPeer bool) err
if err := peer.checkConnectionLimit(); err != nil {
return err
}
// We're dialing the remote so that means connections will come from random ports
addrStr := peer.router.NormalisePeerAddr(peerAddr)
tcpAddr, tcpErr := net.ResolveTCPAddr("tcp4", addrStr)
udpAddr, udpErr := net.ResolveUDPAddr("udp4", addrStr)
tcpAddr, tcpErr := net.ResolveTCPAddr("tcp4", peerAddr)
udpAddr, udpErr := net.ResolveUDPAddr("udp4", peerAddr)
if tcpErr != nil || udpErr != nil {
// they really should have the same value, but just in case...
if tcpErr == nil {
-10
View File
@@ -417,13 +417,3 @@ func (router *Router) applyTopologyUpdate(update []byte) (PeerNameSet, PeerNameS
}
return origUpdate, newUpdate, nil
}
// given an address like '1.2.3.4:567', return the address if it has a port,
// otherwise return the address with the default port number for the router
func (router *Router) NormalisePeerAddr(peerAddr string) string {
_, _, err := net.SplitHostPort(peerAddr)
if err == nil {
return peerAddr
}
return fmt.Sprintf("%s:%d", peerAddr, router.Port)
}