Add Peer.Torrent

This was for accessing from callback events.
This commit is contained in:
Matt Joiner 2023-03-01 14:17:29 +11:00
parent 31bbd435f9
commit c069849b40
No known key found for this signature in database
GPG Key ID: 6B990B8185E7F782
1 changed files with 7 additions and 0 deletions

View File

@ -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{}
}