change limit priority logic

This commit is contained in:
YouROK
2021-08-17 15:01:07 +03:00
parent 7515d6bd01
commit 862ad66e3b

View File

@@ -247,13 +247,21 @@ func (c *Cache) getRemPieces() []*Piece {
} }
pc := r.getReaderPiece() pc := r.getReaderPiece()
end := r.getPiecesRange().End end := r.getPiecesRange().End
limit := 5 limit := 16777216 / c.pieceLength * 5
if limit > 40 {
limit = 40
}
count := limit
for pc <= end && limit > 0 { for pc <= end && limit > 0 {
if !c.pieces[pc].Complete { if !c.pieces[pc].Complete {
if c.torrent.PieceState(pc).Priority == torrent.PiecePriorityNone { if c.torrent.PieceState(pc).Priority == torrent.PiecePriorityNone {
if limit > count/2 {
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityHigh)
} else {
c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNormal) c.torrent.Piece(pc).SetPriority(torrent.PiecePriorityNormal)
} }
}
limit-- limit--
} }
pc++ pc++