peer.go | 7 +++++++ diff --git a/peer.go b/peer.go index dbff1ba155efda1a59312c234c312bad57f61509..d5ed19e53ac45471b589327afe0443805194f742 100644 --- a/peer.go +++ b/peer.go @@ -126,6 +126,13 @@ // The peer was given directly, such as through a magnet link. PeerSourceDirect = "M" ) +// Returns the Torrent a Peer belongs to. Shouldn't change for the lifetime of the Peer. May be nil +// if we are the receiving end of a connection and the handshake hasn't been received or accepted +// yet. +func (p *Peer) Torrent() *Torrent { + return p.t +} + func (p *Peer) initRequestState() { p.requestState.Requests = &peerRequests{} }