Quick fix for missing MetaInfo.Announce everywhere with trackers

This commit is contained in:
Matt Joiner 2017-02-13 22:28:42 +11:00
parent b868a6b9e2
commit b7a8d08bbf
3 changed files with 18 additions and 3 deletions

View File

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

4
t.go
View File

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

View File

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