use fixed RA

This commit is contained in:
nikk gitanes
2023-10-31 11:38:54 +03:00
parent 1e7228550b
commit df77023c22

View File

@@ -193,18 +193,21 @@ func (t *Torrent) progressEvent() {
} }
func (t *Torrent) updateRA() { func (t *Torrent) updateRA() {
t.muTorrent.Lock() // t.muTorrent.Lock()
defer t.muTorrent.Unlock() // defer t.muTorrent.Unlock()
if t.Torrent != nil && t.Torrent.Info() != nil { // if t.Torrent != nil && t.Torrent.Info() != nil {
pieceLen := t.Torrent.Info().PieceLength // pieceLen := t.Torrent.Info().PieceLength
adj := pieceLen * int64(t.Torrent.Stats().ActivePeers) / int64(1+t.cache.Readers()) // adj := pieceLen * int64(t.Torrent.Stats().ActivePeers) / int64(1+t.cache.Readers())
if adj < pieceLen { // switch {
adj = pieceLen // case adj < pieceLen:
//} else if adj > pieceLen*4 { // adj = pieceLen
// adj = pieceLen * 4 // case adj > pieceLen*4:
} // adj = pieceLen * 4
go t.cache.AdjustRA(adj) // }
} // go t.cache.AdjustRA(adj)
// }
adj := int64(16 << 20) // 16 MB fixed RA
go t.cache.AdjustRA(adj)
} }
func (t *Torrent) expired() bool { func (t *Torrent) expired() bool {