From: Matt Joiner Date: Wed, 1 Mar 2023 03:17:29 +0000 (+1100) Subject: Add Peer.Torrent X-Git-Tag: v1.49.0~1 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=c069849b404065442639bb62b0b9e01469cf5b87;p=btrtrc.git Add Peer.Torrent This was for accessing from callback events. --- diff --git a/peer.go b/peer.go index dbff1ba1..d5ed19e5 100644 --- 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{} }