]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Make some overlap of piece priorities
authorMatt Joiner <anacrolix@gmail.com>
Sun, 7 Dec 2014 03:18:17 +0000 (21:18 -0600)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 7 Dec 2014 03:18:17 +0000 (21:18 -0600)
The goal is to reduce duplicating requests on higher priority pieces.

connection.go

index f8855aeedc7ddbfdae43dea235ad0948b9d2eea3..05b037ab0d634a3714c1ba7396d627f14ccfa75f 100644 (file)
@@ -98,11 +98,11 @@ func (cn *connection) pendPiece(piece int, priority piecePriority) {
        // favouring of higher priority pieces.
        switch priority {
        case piecePriorityReadahead:
-               key -= len(cn.piecePriorities)
+               key -= len(cn.piecePriorities) / 3
        case piecePriorityNext:
-               key -= 2 * len(cn.piecePriorities)
+               key -= len(cn.piecePriorities) / 2
        case piecePriorityNow:
-               key -= 3 * len(cn.piecePriorities)
+               key -= len(cn.piecePriorities)
        }
        cn.pieceRequestOrder.SetPiece(piece, key)
 }