Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

Commit 96d46a9

Browse files
authored
Merge pull request #245 from aleitner/master
Remove bridgeUri from config
2 parents ad48006 + 8d47e96 commit 96d46a9

File tree

6 files changed

+35
-31
lines changed

6 files changed

+35
-31
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,19 @@ storjshare start --config path/to/config.json
340340
* starting share with config at path/to/config.json
341341
```
342342

343+
#### Updating storjshare and restoring sessions
344+
345+
If you want to upgrade storjshare you can save your current session and
346+
reload it after updating
347+
348+
```
349+
storjshare save
350+
storjshare killall
351+
npm install -g storjshare-daemon
352+
storjshare daemon &
353+
storjshare load
354+
```
355+
343356
## License
344357

345358
Storj Share - Daemon + CLI for farming data on the Storj network.

example/farmer.config.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
"maxOfferConcurrency": 3,
1313
// If the seedList is empty, use this bridge to discover seeds
1414
// Following a transfer, also send an exchange report to this bridge
15-
"bridgeUri": "https://api.storj.io",
15+
"bridges":[
16+
{
17+
"url": "https://api.storj.io",
18+
"extendedKey": "xpub6AHweYHAxk1EhJSBctQD1nLWPog6Sy2eTpKQLExR1hfzTyyZQWvU4EYNXv1NJN7GpLYXnDLt4PzN874g6zSjAQdFCHZN7U7nbYKYVDUzD42"
19+
}
20+
],
1621
// Known preferred seeds in form of a storj URI
1722
// Example: "storj://[ip.or.hostname]:[port]/[nodeid]"
1823
"seedList": [],

lib/config/farmer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const config = require('rc')('storjfarmer', {
1717
'0f03020202'
1818
],
1919
maxOfferConcurrency: 3,
20-
bridgeUri: 'https://api.storj.io',
2120
seedList: [],
2221
rpcAddress: '127.0.0.1',
2322
rpcPort: 4000,

lib/utils.js

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const net = require('net');
99
const fs = require('fs');
1010
const storj = require('storj-lib');
1111
const {bitcore} = storj.deps;
12-
const du = require('du');
13-
const diskspace = require('fd-diskspace').diskSpace;
12+
const du = require('du'); // Get amount used
13+
const disk = require('diskusage'); // Get amount free
1414
const assert = require('assert');
1515
const bytes = require('bytes');
1616

@@ -107,6 +107,9 @@ exports.validateAllocation = function(conf, callback) {
107107

108108
self.getFreeSpace(conf.storagePath, function(err, free) {
109109
var allocatedSpace = bytes.parse(conf.storageAllocation);
110+
if (err) {
111+
callback(err);
112+
}
110113

111114
self.getDirectorySize(conf.storagePath, function(err, usedSpaceBytes) {
112115
if (err) {
@@ -176,34 +179,12 @@ exports.getFreeSpace = function(path, callback) {
176179
return callback(null, 0);
177180
}
178181

179-
diskspace(function(err, result) {
180-
/* jshint maxcomplexity:10 */
182+
disk.check(path, function(err, info) {
181183
if (err) {
182184
return callback(err);
183185
}
184186

185-
let free = 0;
186-
187-
for (let disk in result.disks) {
188-
let diskDrive = disk;
189-
190-
/* istanbul ignore if */
191-
if (process.platform === 'win32') {
192-
diskDrive += ':\\';
193-
}
194-
195-
if (exports.existsSync(diskDrive)) {
196-
if (fs.statSync(path).dev === fs.statSync(diskDrive).dev) {
197-
// NB: The `df` command on gnu+linux returns KB by default
198-
// NB: so we need to convert to bytes.
199-
free = process.platform === 'win32' ?
200-
result.disks[disk].free :
201-
result.disks[disk].free * 1000;
202-
}
203-
}
204-
}
205-
206-
return callback(null, free);
187+
return callback(null, info.available);
207188
});
208189
};
209190

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "storjshare-daemon",
3-
"version": "4.0.1",
3+
"version": "4.0.2",
44
"description": "daemon + process manager for sharing space on the storj network",
55
"main": "index.js",
66
"bin": {
@@ -69,14 +69,14 @@
6969
"dnode": "^1.2.2",
7070
"du": "^0.1.0",
7171
"editor": "^1.0.0",
72-
"fd-diskspace": "git+https://github.com/littleskunk/fd-diskspace#1e07a35e4023a222b10ff5eafcfe8a812097dea2",
72+
"diskusage": "^0.2.3",
7373
"fslogger": "^2.0.1",
7474
"kad-logger-json": "^0.1.2",
7575
"mkdirp": "^0.5.1",
7676
"pretty-ms": "^2.1.0",
7777
"rc": "^1.1.6",
7878
"readable-stream": "^2.2.2",
79-
"storj-lib": "^7.0.0",
79+
"storj-lib": "^7.0.2",
8080
"strip-json-comments": "^2.0.1",
8181
"tail": "^1.2.1",
8282
"touch": "3.1.0"

script/farmer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,18 @@ const farmer = storj.Farmer(config);
4343

4444
config.logger.on('log', () => farmerState.lastActivity = Date.now());
4545
config.logger.pipe(process.stdout);
46+
4647
farmer.join((err) => {
4748
if (err) {
4849
config.logger.error(err.message);
4950
process.exit(1);
5051
}
52+
})
53+
farmer.on('bridgeConnected', (bridge) => {
54+
config.logger.info('Connected to bridge: %s', bridge.url);
5155
});
56+
farmer.runSpaceCheck(); // Check if we can accept offers
57+
farmer.connectBridges();
5258

5359
function transportInitialized() {
5460
return farmer.transport._requiresTraversal !== undefined

0 commit comments

Comments
 (0)