Skip to content

Commit

Permalink
fix calculation of speed limit #41
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Nov 7, 2021
1 parent 3054d79 commit d1d9dc7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions torrent/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,13 @@ func NewSession(cfg Config) (*Session, error) {
},
},
}
dlSpeed := cfg.SpeedLimitDownload * 1024
if cfg.SpeedLimitDownload > 0 {
c.bucketDownload = ratelimit.NewBucketWithRate(float64(cfg.SpeedLimitDownload), cfg.SpeedLimitDownload)
c.bucketDownload = ratelimit.NewBucketWithRate(float64(dlSpeed), dlSpeed)
}
ulSpeed := cfg.SpeedLimitUpload * 1024
if cfg.SpeedLimitUpload > 0 {
c.bucketUpload = ratelimit.NewBucketWithRate(float64(cfg.SpeedLimitUpload), cfg.SpeedLimitUpload)
c.bucketUpload = ratelimit.NewBucketWithRate(float64(ulSpeed), ulSpeed)
}
err = c.startBlocklistReloader()
if err != nil {
Expand Down

0 comments on commit d1d9dc7

Please sign in to comment.