]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Change piece prioritization
authorMatt Joiner <anacrolix@gmail.com>
Sat, 21 Feb 2015 04:02:31 +0000 (15:02 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 21 Feb 2015 04:02:31 +0000 (15:02 +1100)
client.go
connection.go

index d6ab47270503d319956b39200f413aeeb14b1c2c..f3f8a59960cb81a4ca9cb9ad8e084204ae491086 100644 (file)
--- 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
index 53d23994d523b261fb2446032b143e6e8668c09d..6cc90c24c61fad0eaba8e083ac6cc5dd61752e31 100644 (file)
@@ -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)
 }