From 06ebc4c37e50e9e8d012085cd352308abb2338c6 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sun, 2 Aug 2015 03:55:48 +1000 Subject: [PATCH] Explicitly import Torrent.InfoHash --- misc.go | 4 ++-- t.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/misc.go b/misc.go index 95c5c1e6..ab6dcf78 100644 --- a/misc.go +++ b/misc.go @@ -27,11 +27,11 @@ type ( pieceSum [20]byte ) -func (ih *InfoHash) AsString() string { +func (ih InfoHash) AsString() string { return string(ih[:]) } -func (ih *InfoHash) HexString() string { +func (ih InfoHash) HexString() string { return fmt.Sprintf("%x", ih[:]) } diff --git a/t.go b/t.go index 8a561661..607aa304 100644 --- a/t.go +++ b/t.go @@ -12,6 +12,10 @@ type Torrent struct { *torrent } +func (t Torrent) InfoHash() InfoHash { + return t.torrent.InfoHash +} + // Closed when the info (.Info()) for the torrent has become available. Using // features of Torrent that require the info before it is available will have // undefined behaviour. @@ -49,7 +53,7 @@ func (t Torrent) NumPieces() int { func (t Torrent) Drop() { t.cl.mu.Lock() - t.cl.dropTorrent(t.InfoHash) + t.cl.dropTorrent(t.torrent.InfoHash) t.cl.mu.Unlock() } -- 2.44.0