diff --git a/metainfo/metainfo.go b/metainfo/metainfo.go index decfc3a0..14ff8d04 100644 --- a/metainfo/metainfo.go +++ b/metainfo/metainfo.go @@ -78,3 +78,18 @@ func (mi *MetaInfo) Magnet(displayName string, infoHash Hash) (m Magnet) { m.InfoHash = infoHash return } + +func (mi *MetaInfo) FlatTrackers() (ret []string) { + m := make(map[string]struct{}) + for _, t := range mi.AnnounceList { + for _, s := range t { + m[s] = struct{}{} + } + } + m[mi.Announce] = struct{}{} + ret = make([]string, 0, len(m)) + for s := range m { + ret = append(ret, s) + } + return +} diff --git a/t.go b/t.go index ed810a5f..e6d231ca 100644 --- a/t.go +++ b/t.go @@ -197,8 +197,8 @@ func (t *Torrent) String() string { return s } -func (t *Torrent) AddTrackers(announceList [][]string) { +func (t *Torrent) AddTrackers(urls []string) { t.cl.mu.Lock() defer t.cl.mu.Unlock() - t.addTrackers(announceList) + t.addTrackers([][]string{urls}) } diff --git a/torrent.go b/torrent.go index 929e0bc6..d515bc95 100644 --- a/torrent.go +++ b/torrent.go @@ -1354,7 +1354,7 @@ func (t *Torrent) pieceHashed(piece int, correct bool) { if correct { pieceHashedCorrect.Add(1) } else { - log.Printf("%s: piece %d (%x) failed hash: %d connections contributed", t, piece, p.Hash, len(touchers)) + log.Printf("%s: piece %d (%v) failed hash: %d connections contributed", t, piece, p.Hash, len(touchers)) pieceHashedNotCorrect.Add(1) } }