Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCas <6506529+ThaUnknown@users.noreply.github.com>2022-05-11 03:48:56 +0300
committerGitHub <noreply@github.com>2022-05-11 03:48:56 +0300
commit522ee4cd14d3b41e92c3978e9816cb66e00233f0 (patch)
tree34ef0305fa6fd2f8ddf11ce7c0f1d0a2fea766ed
parenta2f8c1e30ea3c34f0535606a65f7fa75964e6cc4 (diff)
fix: measure transfer rates without using timeouts (#2314)
-rw-r--r--index.js6
-rw-r--r--lib/torrent.js6
-rw-r--r--package.json2
3 files changed, 7 insertions, 7 deletions
diff --git a/index.js b/index.js
index 31c318b..e7b56a8 100644
--- a/index.js
+++ b/index.js
@@ -15,7 +15,7 @@ const Peer = require('simple-peer')
const queueMicrotask = require('queue-microtask')
const randombytes = require('randombytes')
const sha1 = require('simple-sha1')
-const speedometer = require('speedometer')
+const throughput = require('throughput')
const { ThrottleGroup } = require('speed-limiter')
const ConnPool = require('./lib/conn-pool.js') // browser exclude
const Torrent = require('./lib/torrent.js')
@@ -115,8 +115,8 @@ class WebTorrent extends EventEmitter {
}
// stats
- this._downloadSpeed = speedometer()
- this._uploadSpeed = speedometer()
+ this._downloadSpeed = throughput()
+ this._uploadSpeed = throughput()
if (opts.dht !== false && typeof DHT === 'function' /* browser exclude */) {
// use a single DHT instance for all torrents, so the routing table can be reused
diff --git a/lib/torrent.js b/lib/torrent.js
index 51c0552..ff4dcdd 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -26,7 +26,7 @@ const pump = require('pump')
const queueMicrotask = require('queue-microtask')
const randomIterate = require('random-iterate')
const sha1 = require('simple-sha1')
-const speedometer = require('speedometer')
+const throughput = require('throughput')
const utMetadata = require('ut_metadata')
const utPex = require('ut_pex') // browser exclude
@@ -121,8 +121,8 @@ class Torrent extends EventEmitter {
// stats
this.received = 0
this.uploaded = 0
- this._downloadSpeed = speedometer()
- this._uploadSpeed = speedometer()
+ this._downloadSpeed = throughput()
+ this._uploadSpeed = throughput()
// for cleanup
this._servers = []
diff --git a/package.json b/package.json
index 43b8376..1c234ce 100644
--- a/package.json
+++ b/package.json
@@ -71,10 +71,10 @@
"simple-peer": "^9.11.1",
"simple-sha1": "^3.1.0",
"speed-limiter": "^1.0.2",
- "speedometer": "^1.1.0",
"stream-to-blob": "^2.0.1",
"stream-to-blob-url": "^3.0.2",
"stream-with-known-length-to-buffer": "^1.0.4",
+ "throughput": "^1.0.0",
"torrent-discovery": "^9.4.10",
"torrent-piece": "^2.0.1",
"unordered-array-remove": "^1.0.2",