diff --git a/README.md b/README.md index f73af2c..fa6327c 100644 --- a/README.md +++ b/README.md @@ -340,6 +340,19 @@ storjshare start --config path/to/config.json * starting share with config at path/to/config.json ``` +#### Updating storjshare and restoring sessions + +If you want to upgrade storjshare you can save your current session and +reload it after updating + +``` +storjshare save +storjshare killall +npm install -g storjshare-daemon +storjshare daemon & +storjshare load +``` + ## License Storj Share - Daemon + CLI for farming data on the Storj network. diff --git a/example/farmer.config.json b/example/farmer.config.json index f13673e..9fe2830 100644 --- a/example/farmer.config.json +++ b/example/farmer.config.json @@ -12,7 +12,12 @@ "maxOfferConcurrency": 3, // If the seedList is empty, use this bridge to discover seeds // Following a transfer, also send an exchange report to this bridge - "bridgeUri": "https://api.storj.io", + "bridges":[ + { + "url": "https://api.storj.io", + "extendedKey": "xpub6AHweYHAxk1EhJSBctQD1nLWPog6Sy2eTpKQLExR1hfzTyyZQWvU4EYNXv1NJN7GpLYXnDLt4PzN874g6zSjAQdFCHZN7U7nbYKYVDUzD42" + } + ], // Known preferred seeds in form of a storj URI // Example: "storj://[ip.or.hostname]:[port]/[nodeid]" "seedList": [], diff --git a/lib/config/farmer.js b/lib/config/farmer.js index 1b3b2bc..7195358 100644 --- a/lib/config/farmer.js +++ b/lib/config/farmer.js @@ -17,7 +17,6 @@ const config = require('rc')('storjfarmer', { '0f03020202' ], maxOfferConcurrency: 3, - bridgeUri: 'https://api.storj.io', seedList: [], rpcAddress: '127.0.0.1', rpcPort: 4000, diff --git a/lib/utils.js b/lib/utils.js index 20851d2..919e176 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -9,8 +9,8 @@ const net = require('net'); const fs = require('fs'); const storj = require('storj-lib'); const {bitcore} = storj.deps; -const du = require('du'); -const diskspace = require('fd-diskspace').diskSpace; +const du = require('du'); // Get amount used +const disk = require('diskusage'); // Get amount free const assert = require('assert'); const bytes = require('bytes'); @@ -107,6 +107,9 @@ exports.validateAllocation = function(conf, callback) { self.getFreeSpace(conf.storagePath, function(err, free) { var allocatedSpace = bytes.parse(conf.storageAllocation); + if (err) { + callback(err); + } self.getDirectorySize(conf.storagePath, function(err, usedSpaceBytes) { if (err) { @@ -176,34 +179,12 @@ exports.getFreeSpace = function(path, callback) { return callback(null, 0); } - diskspace(function(err, result) { - /* jshint maxcomplexity:10 */ + disk.check(path, function(err, info) { if (err) { return callback(err); } - let free = 0; - - for (let disk in result.disks) { - let diskDrive = disk; - - /* istanbul ignore if */ - if (process.platform === 'win32') { - diskDrive += ':\\'; - } - - if (exports.existsSync(diskDrive)) { - if (fs.statSync(path).dev === fs.statSync(diskDrive).dev) { - // NB: The `df` command on gnu+linux returns KB by default - // NB: so we need to convert to bytes. - free = process.platform === 'win32' ? - result.disks[disk].free : - result.disks[disk].free * 1000; - } - } - } - - return callback(null, free); + return callback(null, info.available); }); }; diff --git a/package.json b/package.json index c0eea9e..a5e62e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "storjshare-daemon", - "version": "4.0.1", + "version": "4.0.2", "description": "daemon + process manager for sharing space on the storj network", "main": "index.js", "bin": { @@ -69,14 +69,14 @@ "dnode": "^1.2.2", "du": "^0.1.0", "editor": "^1.0.0", - "fd-diskspace": "git+https://github.com/littleskunk/fd-diskspace#1e07a35e4023a222b10ff5eafcfe8a812097dea2", + "diskusage": "^0.2.3", "fslogger": "^2.0.1", "kad-logger-json": "^0.1.2", "mkdirp": "^0.5.1", "pretty-ms": "^2.1.0", "rc": "^1.1.6", "readable-stream": "^2.2.2", - "storj-lib": "^7.0.0", + "storj-lib": "^7.0.2", "strip-json-comments": "^2.0.1", "tail": "^1.2.1", "touch": "3.1.0" diff --git a/script/farmer.js b/script/farmer.js index 4200d39..e012a7a 100755 --- a/script/farmer.js +++ b/script/farmer.js @@ -43,12 +43,18 @@ const farmer = storj.Farmer(config); config.logger.on('log', () => farmerState.lastActivity = Date.now()); config.logger.pipe(process.stdout); + farmer.join((err) => { if (err) { config.logger.error(err.message); process.exit(1); } +}) +farmer.on('bridgeConnected', (bridge) => { + config.logger.info('Connected to bridge: %s', bridge.url); }); +farmer.runSpaceCheck(); // Check if we can accept offers +farmer.connectBridges(); function transportInitialized() { return farmer.transport._requiresTraversal !== undefined