Skip to content

Commit

Permalink
display remote pieces progress per wire
Browse files Browse the repository at this point in the history
this one is costly, could use some caching.
  • Loading branch information
astro committed Nov 22, 2014
1 parent e5edb84 commit 12cbf81
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} ' +
Expand Down

0 comments on commit 12cbf81

Please sign in to comment.