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
path: root/bin
diff options
context:
space:
mode:
authorAstro <astro@spaceboyz.net>2014-11-22 04:40:00 +0300
committerAstro <astro@spaceboyz.net>2014-11-22 04:41:50 +0300
commit12cbf810d6f3a751b1164be9503715d047ab9561 (patch)
tree154db3001d6ab65bef0f1260141c01e1571e87ab /bin
parente5edb8447e503c14ce34bc05cd1c9191188f88b1 (diff)
display remote pieces progress per wire
this one is costly, could use some caching.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cmd.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/bin/cmd.js b/bin/cmd.js
index 5276353..7b336db 100755
--- a/bin/cmd.js
+++ b/bin/cmd.js
@@ -384,12 +384,24 @@ function onReady () {
linesremaining -= 1
wires.every(function (wire) {
+ var progress = '?'
+ if (torrent.parsedTorrent) {
+ var bits = 0
+ var piececount = Math.ceil(torrent.parsedTorrent.length / torrent.parsedTorrent.pieceLength)
+ for(var i = 0; i < piececount; i++) {
+ if (wire.peerPieces.get(i)) {
+ bits++
+ }
+ }
+ progress = bits === piececount ? 'S' : Math.floor(100 * bits / piececount) + '%'
+ }
var tags = []
if (wire.peerChoking) tags.push('choked')
var reqStats = wire.requests.map(function(req) {
return req.piece;
})
clivas.line(
+ '{3:' + progress + '} ' +
'{25+magenta:' + wire.remoteAddress + '} {10:'+bytes(wire.downloaded)+'} ' +
'{10+cyan:' + bytes(wire.downloadSpeed()) + '/s} ' +
'{10+red:' + bytes(wire.uploadSpeed()) + '/s} ' +