diff options
author | Astro <astro@spaceboyz.net> | 2014-11-22 04:40:00 +0300 |
---|---|---|
committer | Astro <astro@spaceboyz.net> | 2014-11-22 04:41:50 +0300 |
commit | 12cbf810d6f3a751b1164be9503715d047ab9561 (patch) | |
tree | 154db3001d6ab65bef0f1260141c01e1571e87ab /bin | |
parent | e5edb8447e503c14ce34bc05cd1c9191188f88b1 (diff) |
display remote pieces progress per wire
this one is costly, could use some caching.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cmd.js | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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} ' + |