From 3a3d661499e79490b906cfe44ad0bee7c3d07afd Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 22 Nov 2014 02:37:54 +0100 Subject: [PATCH 1/4] display pieces that are in progress --- bin/cmd.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bin/cmd.js b/bin/cmd.js index 8c8d1bcf..b7bb6495 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -366,6 +366,23 @@ function onReady () { clivas.line('{80:}') linesremaining -= 8 + var pieces = torrent.storage.pieces + var piecesBar = [] + for(var i = 0; i < pieces.length; i++) { + var piece = pieces[i] + if (piece.verified || piece.blocksWritten === 0) { + continue; + } + var bar = '' + for(var j = 0; j < piece.blocks.length; j++) { + bar += piece.blocks[j] ? '{green:█}' : '{red:█}'; + } + clivas.line('{4+cyan:' + i + '} ' + bar); + linesremaining -= 1 + } + clivas.line('{80:}') + linesremaining -= 1 + wires.every(function (wire) { var tags = [] if (wire.peerChoking) tags.push('choked') From 37b7251657acd3cee57ff36ad660c70a0ccfa707 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 22 Nov 2014 02:39:09 +0100 Subject: [PATCH 2/4] display requests per wire --- bin/cmd.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/cmd.js b/bin/cmd.js index b7bb6495..d3a6bdb0 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -386,10 +386,14 @@ function onReady () { wires.every(function (wire) { var tags = [] if (wire.peerChoking) tags.push('choked') + var reqStats = wire.requests.map(function(req) { + return req.piece; + }) clivas.line( '{25+magenta:' + wire.remoteAddress + '} {10:'+bytes(wire.downloaded)+'} ' + '{10+cyan:' + bytes(wire.downloadSpeed()) + '/s} ' + - '{15+grey:' + tags.join(', ') + '}' + '{15+grey:' + tags.join(', ') + '}' + + '{15+cyan:' + reqStats.join(' ') + '}' ) peerslisted++ return linesremaining - peerslisted > 4 From e5edb8447e503c14ce34bc05cd1c9191188f88b1 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 22 Nov 2014 02:39:54 +0100 Subject: [PATCH 3/4] display wire upload speed --- bin/cmd.js | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/cmd.js b/bin/cmd.js index d3a6bdb0..5276353c 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -392,6 +392,7 @@ function onReady () { clivas.line( '{25+magenta:' + wire.remoteAddress + '} {10:'+bytes(wire.downloaded)+'} ' + '{10+cyan:' + bytes(wire.downloadSpeed()) + '/s} ' + + '{10+red:' + bytes(wire.uploadSpeed()) + '/s} ' + '{15+grey:' + tags.join(', ') + '}' + '{15+cyan:' + reqStats.join(' ') + '}' ) From 12cbf810d6f3a751b1164be9503715d047ab9561 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 22 Nov 2014 02:40:00 +0100 Subject: [PATCH 4/4] display remote pieces progress per wire this one is costly, could use some caching. --- bin/cmd.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/cmd.js b/bin/cmd.js index 5276353c..7b336dbc 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} ' +