From 92e0679b04dfb356286d78eddc2fdc3a731fcf4c Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 21 Feb 2015 15:02:31 +1100 Subject: [PATCH] Change piece prioritization --- client.go | 2 +- connection.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index d6ab4727..f3f8a599 100644 --- a/client.go +++ b/client.go @@ -295,7 +295,7 @@ func (cl *Client) readRaisePiecePriorities(t *torrent, off, _len int64) { 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 53d23994..6cc90c24 100644 --- a/connection.go +++ b/connection.go @@ -98,14 +98,15 @@ func (cn *connection) pendPiece(piece int, priority piecePriority) { // 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) } -- 2.48.1