From df77023c225fdb2f9da12c0a9b617a7cdb4885f7 Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Tue, 31 Oct 2023 11:38:54 +0300 Subject: [PATCH] use fixed RA --- server/torr/torrent.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/server/torr/torrent.go b/server/torr/torrent.go index 548b16d..694602e 100644 --- a/server/torr/torrent.go +++ b/server/torr/torrent.go @@ -193,18 +193,21 @@ func (t *Torrent) progressEvent() { } func (t *Torrent) updateRA() { - t.muTorrent.Lock() - defer t.muTorrent.Unlock() - if t.Torrent != nil && t.Torrent.Info() != nil { - pieceLen := t.Torrent.Info().PieceLength - adj := pieceLen * int64(t.Torrent.Stats().ActivePeers) / int64(1+t.cache.Readers()) - if adj < pieceLen { - adj = pieceLen - //} else if adj > pieceLen*4 { - // adj = pieceLen * 4 - } - go t.cache.AdjustRA(adj) - } + // t.muTorrent.Lock() + // defer t.muTorrent.Unlock() + // if t.Torrent != nil && t.Torrent.Info() != nil { + // pieceLen := t.Torrent.Info().PieceLength + // adj := pieceLen * int64(t.Torrent.Stats().ActivePeers) / int64(1+t.cache.Readers()) + // switch { + // case adj < pieceLen: + // adj = pieceLen + // case adj > pieceLen*4: + // adj = pieceLen * 4 + // } + // go t.cache.AdjustRA(adj) + // } + adj := int64(16 << 20) // 16 MB fixed RA + go t.cache.AdjustRA(adj) } func (t *Torrent) expired() bool {