connection.go | 11 +++++++++++ diff --git a/connection.go b/connection.go index d1aa9fcbebf2ac93501d49e87d6d8d4d0b4497b4..56a0ee5b9c72bbbb0c91b56bf4eb10426ee7f7ce 100644 --- a/connection.go +++ b/connection.go @@ -789,6 +789,17 @@ }) } func iterUndirtiedChunks(piece pieceIndex, t *Torrent, f func(chunkSpec) bool) bool { + p := &t.pieces[piece] + if t.requestStrategy == 3 { + for i := pp.Integer(0); i < p.numChunks(); i++ { + if !p.dirtyChunks.Get(bitmap.BitIndex(i)) { + if !f(t.chunkIndexSpec(i, piece)) { + return false + } + } + } + return true + } chunkIndices := t.pieces[piece].undirtiedChunkIndices().ToSortedSlice() // TODO: Use "math/rand".Shuffle >= Go 1.10 return iter.ForPerm(len(chunkIndices), func(i int) bool {