]> Sergey Matveev's repositories - btrtrc.git/blobdiff - download_strategies.go
Add piece ordering per-connection piece request priority
[btrtrc.git] / download_strategies.go
index 0b85d190a5d4a78c7523c56c0de329d5761c324a..572eadba3ccbd6ca78a66bde7541e4cd12fa3bb2 100644 (file)
@@ -45,13 +45,13 @@ func (s *DefaultDownloadStrategy) FillRequests(t *torrent, c *connection) {
        addRequest := func(req request) (again bool) {
                return c.Request(req)
        }
-       for i := range t.Pieces {
-               pieceIndex := c.pieceOrder[i]
+       for e := c.pieceRequestOrder.First(); e != nil; e = e.Next() {
+               pieceIndex := e.Piece()
                if !c.PeerHasPiece(pp.Integer(pieceIndex)) {
-                       continue
+                       panic("piece in request order but peer doesn't have it")
                }
                if !t.wantPiece(pieceIndex) {
-                       continue
+                       panic("unwanted piece in connection request order")
                }
                piece := t.Pieces[pieceIndex]
                for _, cs := range piece.shuffledPendingChunkSpecs() {