Explicitly import Torrent.InfoHash

This commit is contained in:
Matt Joiner 2015-08-02 03:55:48 +10:00
parent e5acfcbb46
commit 06ebc4c37e
2 changed files with 7 additions and 3 deletions

View File

@ -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[:])
}

6
t.go
View File

@ -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()
}