models: include port in peerkey

This commit is contained in:
Jimmy Zelinskie 2015-03-22 18:44:09 -04:00
parent c1a4a6ecbb
commit 92866cfacd

View file

@ -46,8 +46,8 @@ func (e NotFoundError) Error() string { return string(e) }
type PeerList []Peer type PeerList []Peer
type PeerKey string type PeerKey string
func NewPeerKey(peerID string, ip net.IP) PeerKey { func NewPeerKey(peerID string, ip net.IP, port string) PeerKey {
return PeerKey(peerID + "//" + ip.String()) return PeerKey(peerID + "//" + ip.String() + ":" + port)
} }
func (pk PeerKey) IP() net.IP { func (pk PeerKey) IP() net.IP {
@ -88,7 +88,7 @@ func (p *Peer) HasIPv6() bool {
} }
func (p *Peer) Key() PeerKey { func (p *Peer) Key() PeerKey {
return NewPeerKey(p.ID, p.IP) return NewPeerKey(p.ID, p.IP, string(p.Port))
} }
// Torrent is a swarm for a given torrent file. // Torrent is a swarm for a given torrent file.