From c069849b404065442639bb62b0b9e01469cf5b87 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 1 Mar 2023 14:17:29 +1100 Subject: [PATCH] Add Peer.Torrent This was for accessing from callback events. --- peer.go | 7 +++++++ 1 file changed, 7 insertions(+) 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{} } -- 2.44.0