c.PeerPieces = append(c.PeerPieces, false)
}
c.PeerPieces[piece] = true
- if !t.havePiece(piece) {
+ if t.wantPiece(piece) {
me.replenishConnRequests(t, c)
}
}
break
}
t.SaveMetadataPiece(piece, payload[begin:])
+ c.UsefulChunksReceived++
+ c.lastUsefulChunkReceived = time.Now()
if !t.HaveAllMetadataPieces() {
break
}
}
cl.downloadStrategy.TorrentStarted(t)
+ // TODO(anacrolix): I think this should be made available as a method, the
+ // channel only acts as a signal that the metadata has become available.
select {
case t.gotMetainfo <- &metainfo.MetaInfo{
Info: metainfo.InfoEx{
return
}
+func init() {
+ // For shuffling the tracker tiers.
+ mathRand.Seed(time.Now().Unix())
+}
+
// The trackers within each tier must be shuffled before use.
// http://stackoverflow.com/a/12267471/149482
// http://www.bittorrent.org/beps/bep_0012.html#order-of-processing