From 958f30a0341ca323c7cef794b00fe38eed845297 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 22 Aug 2015 14:46:16 +0200 Subject: BREAKING: Use abstract-chunk-store for storage Part of an effort to share more code with `torrent-stream` by @mafintosh: https://github.com/mafintosh/torrent-stream/pull/133 https://github.com/mafintosh/torrent-stream/pull/132 Storage is now based on: https://www.npmjs.com/package/fs-chunk-store (in node) https://www.npmjs.com/package/memory-chunk-store (in the browser) and: https://www.npmjs.com/package/immediate-chunk-store https://www.npmjs.com/package/torrent-piece This is a BREAKING change, since users who pass in custom storage engine with `opts.storage` will need to update their storage backend to be `abstract-chunk-store` compliant: https://www.npmjs.com/package/abstract-chunk-store There are also likely other miscellaneous BREAKING API changes, since this was a huge refactor of the codebase. --- bin/cmd.js | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'bin') diff --git a/bin/cmd.js b/bin/cmd.js index 5cc5b96..2ca529d 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -12,7 +12,6 @@ var networkAddress = require('network-address') var parseTorrent = require('parse-torrent') var path = require('path') var prettyBytes = require('pretty-bytes') -var Storage = require('../lib/storage') var WebTorrent = require('../') var zeroFill = require('zero-fill') @@ -511,7 +510,7 @@ function drawTorrent (torrent) { linesRemaining -= 1 } - var seeding = torrent.storage.done + var seeding = torrent.done if (!seeding) clivas.line('') clivas.line( @@ -540,34 +539,29 @@ function drawTorrent (torrent) { linesRemaining -= 5 if (argv.verbose) { - var pieces = torrent.storage.pieces - var memoryUsage = 0 + var pieces = torrent.pieces for (var i = 0; i < pieces.length; i++) { var piece = pieces[i] - if (piece.buffer) memoryUsage += piece.buffer.length if (piece.verified || (piece.blocksWritten === 0 && !piece.blocks[0])) continue var bar = '' for (var j = 0; j < piece.blocks.length; j++) { - switch (piece.blocks[j]) { - case Storage.BLOCK_BLANK: - bar += '{red:█}' - break - case Storage.BLOCK_RESERVED: - bar += '{blue:█}' - break - case Storage.BLOCK_WRITTEN: - bar += '{green:█}' - break - } + // switch (piece.blocks[j]) { + // case Storage.BLOCK_BLANK: + // bar += '{red:█}' + // break + // case Storage.BLOCK_RESERVED: + // bar += '{blue:█}' + // break + // case Storage.BLOCK_WRITTEN: + // bar += '{green:█}' + // break + // } } clivas.line('{4+cyan:' + i + '} ' + bar) linesRemaining -= 1 } - clivas.line( - '{red:memory usage:} {bold:' + prettyBytes(memoryUsage) + '}' - ) clivas.line('{80:}') - linesRemaining -= 2 + linesRemaining -= 1 } torrent.swarm.wires.every(function (wire) { -- cgit v1.2.3