client.go | 2 +- connection.go | 9 +++++---- diff --git a/client.go b/client.go index d6ab47270503d319956b39200f413aeeb14b1c2c..f3f8a59960cb81a4ca9cb9ad8e084204ae491086 100644 --- a/client.go +++ b/client.go @@ -295,7 +295,7 @@ if index >= t.numPieces() { return } cl.raisePiecePriority(t, index, piecePriorityNext) - for i := 0; i < t.numConnsUnchoked()-2; i++ { + for i := 0; i < 3; i++ { index++ if index >= t.numPieces() { break diff --git a/connection.go b/connection.go index 53d23994d523b261fb2446032b143e6e8668c09d..6cc90c24c61fad0eaba8e083ac6cc5dd61752e31 100644 --- a/connection.go +++ b/connection.go @@ -98,14 +98,15 @@ // There is overlap here so there's some probabilistic favouring of higher // priority pieces. switch priority { case piecePriorityReadahead: - key -= len(cn.piecePriorities) / 3 + key -= len(cn.piecePriorities) case piecePriorityNext: - key -= len(cn.piecePriorities) / 2 + key -= 2 * len(cn.piecePriorities) case piecePriorityNow: - key -= len(cn.piecePriorities) + key -= 3 * len(cn.piecePriorities) } // Favour earlier pieces more than later pieces. - key -= piece / 2 + // key -= piece / 2 + cn.pieceRequestOrder.SetPiece(piece, key) }