download_strategies.go | 10 +++++----- diff --git a/download_strategies.go b/download_strategies.go index c6d0e1e1afa629e691032ed0953528d22413a5e3..43bd1d2d864e97db9cc7344861c8bb39a3d4a860 100644 --- a/download_strategies.go +++ b/download_strategies.go @@ -20,7 +20,7 @@ if c.Interested { if c.PeerChoked { return } - if len(c.Requests) >= c.PeerMaxRequests { + if len(c.Requests) >= (c.PeerMaxRequests+1)/2 { return } } @@ -51,13 +51,13 @@ return } } // Then finish off incomplete pieces in order of bytes remaining. - for _, heatThreshold := range []int{0, 4, 60} { + for _, heatThreshold := range []int{1, 4, 15, 60} { for e := t.PiecesByBytesLeft.Front(); e != nil; e = e.Next() { pieceIndex := pp.Integer(e.Value.(int)) - // for _, chunkSpec := range t.Pieces[pieceIndex].shuffledPendingChunkSpecs() { - for chunkSpec := range t.Pieces[pieceIndex].PendingChunkSpecs { + for _, chunkSpec := range t.Pieces[pieceIndex].shuffledPendingChunkSpecs() { + // for chunkSpec := range t.Pieces[pieceIndex].PendingChunkSpecs { r := request{pieceIndex, chunkSpec} - if th[r] > heatThreshold { + if th[r] >= heatThreshold { continue } if !addRequest(r) {