Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couple of changes to cmd.js #600

Closed
wants to merge 12 commits into from

Style.

Signed-off-by: Vincent Frentzel <vincent@frentzel.eu>
  • Loading branch information
Vincent Frentzel
Vincent Frentzel committed Feb 7, 2016
commit aaf7fb3abecba90cbc0b3a5f1fc02a2a7a2963d4
@@ -555,41 +555,41 @@ function drawTorrent (torrent) {

if (argv.verbose) {
torrent.swarm.wires.every(function (wire) {
var progress = '?'
if (torrent.length) {
var bits = 0
var piececount = Math.ceil(torrent.length / torrent.pieceLength)
for (var i = 0; i < piececount; i++) {
if (wire.peerPieces.get(i)) {
bits++
}
var progress = '?'
if (torrent.length) {
var bits = 0
var piececount = Math.ceil(torrent.length / torrent.pieceLength)
for (var i = 0; i < piececount; i++) {
if (wire.peerPieces.get(i)) {
bits++
}
progress = bits === piececount ? 'S' : Math.floor(100 * bits / piececount) + '%'
}

var str = '{3:%s} {25+magenta:%s} {10:%s} {12+cyan:%s/s} {12+red:%s/s}'
var args = [
progress,
wire.remoteAddress
? (wire.remoteAddress + ':' + wire.remotePort)
: 'Unknown',
prettyBytes(wire.downloaded),
prettyBytes(wire.downloadSpeed()),
prettyBytes(wire.uploadSpeed())
]

str += ' {15+grey:%s} {10+grey:%s}'
var tags = []
if (wire.requests.length > 0) tags.push(wire.requests.length + ' reqs')
if (wire.peerChoking) tags.push('choked')
var reqStats = wire.requests.map(function (req) { return req.piece })
args.push(tags.join(', '), reqStats.join(' '))

line.apply(undefined, [].concat(str, args))

peerslisted += 1
return linesRemaining > 4
})
progress = bits === piececount ? 'S' : Math.floor(100 * bits / piececount) + '%'
}

var str = '{3:%s} {25+magenta:%s} {10:%s} {12+cyan:%s/s} {12+red:%s/s}'
var args = [
progress,
wire.remoteAddress
? (wire.remoteAddress + ':' + wire.remotePort)
: 'Unknown',
prettyBytes(wire.downloaded),
prettyBytes(wire.downloadSpeed()),
prettyBytes(wire.uploadSpeed())
]

str += ' {15+grey:%s} {10+grey:%s}'
var tags = []
if (wire.requests.length > 0) tags.push(wire.requests.length + ' reqs')
if (wire.peerChoking) tags.push('choked')
var reqStats = wire.requests.map(function (req) { return req.piece })
args.push(tags.join(', '), reqStats.join(' '))

line.apply(undefined, [].concat(str, args))

peerslisted += 1
return linesRemaining > 4
})

if (torrent.numPeers > peerslisted) {
line('{60:}')
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.