]> Sergey Matveev's repositories - btrtrc.git/blobdiff - peer.go
Add Peer.Torrent
[btrtrc.git] / peer.go
diff --git a/peer.go b/peer.go
index dbff1ba155efda1a59312c234c312bad57f61509..d5ed19e53ac45471b589327afe0443805194f742 100644 (file)
--- a/peer.go
+++ b/peer.go
@@ -126,6 +126,13 @@ const (
        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{}
 }