Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global down/up speed limit #1762

Open
wants to merge 2 commits into
base: master
from
Open
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

fix spaces

  • Loading branch information
Ivan Gorbanev
Ivan Gorbanev committed Oct 21, 2019
commit f7d3cb3ecbdaf62e7441a8f7cd31b7914f703a06
@@ -81,8 +81,8 @@ class WebTorrent extends EventEmitter {
)

this.throttleGroups = {
down: new ThrottleGroup({rate: this.downloadLimit}),
up: new ThrottleGroup({rate: this.uploadLimit})
down: new ThrottleGroup({ rate: this.downloadLimit }),
up: new ThrottleGroup({ rate: this.uploadLimit })
}

if (this.tracker) {
@@ -367,7 +367,7 @@ class WebTorrent extends EventEmitter {
* Set global download throttle rate
* @param {Number} rate
*/
throttleDownload(rate) {
throttleDownload (rate) {
if (!Number(rate) || Number(rate) < 0) return
this.throttleGroups.down.bucket.bucketSize = rate
this.throttleGroups.down.bucket.tokensPerInterval = rate
@@ -377,7 +377,7 @@ class WebTorrent extends EventEmitter {
* Set global upload throttle rate
* @param {Number} rate
*/
throttleUpload(rate) {
throttleUpload (rate) {
if (!Number(rate) || Number(rate) < 0) return
this.throttleGroups.up.bucket.bucketSize = rate
this.throttleGroups.up.bucket.tokensPerInterval = rate
@@ -151,12 +151,12 @@ class Peer {
if (this.swarm && !this.sentHandshake) this.handshake()
}

clearPipes() {
clearPipes () {
this.wire.unpipe()
this.conn.unpipe()
}

setThrottlePipes() {
setThrottlePipes () {
this.conn.pipe(this.swarm.client.throttleGroups.down.throttle())
.pipe(this.wire)
.pipe(this.swarm.client.throttleGroups.up.throttle())
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.