Quick fix for missing MetaInfo.Announce everywhere with trackers
This commit is contained in:
parent
b868a6b9e2
commit
b7a8d08bbf
|
@ -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
4
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})
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue