Move to swarmjs and await geth ready
Move to swarmjs library (in embark-framework). Wait for geth to start before start of swarm check.
This commit is contained in:
parent
b5e8546ebd
commit
fcb75dee11
|
@ -1,9 +1,10 @@
|
|||
const UploadSwarm = require('./upload.js');
|
||||
const utils = require('../../utils/utils.js');
|
||||
const fs = require('../../core/fs.js');
|
||||
const SwarmGW = require('swarmgw');
|
||||
const SwarmJS = require('swarmjs');
|
||||
// TODO: not great, breaks module isolation
|
||||
const StorageProcessesLauncher = require('../storage/storageProcessesLauncher');
|
||||
const constants = require('../../constants.json');
|
||||
|
||||
class Swarm {
|
||||
|
||||
|
@ -26,20 +27,26 @@ class Swarm {
|
|||
if (!this.isSwarmEnabledInTheConfig()) {
|
||||
return;
|
||||
}
|
||||
this.swarm = new SwarmGW({gateway: this.providerUrl});
|
||||
console.dir('STARTING SWARMJS');
|
||||
this.swarm = new SwarmJS({gateway: this.providerUrl});
|
||||
|
||||
this.setServiceCheck();
|
||||
this.addProviderToEmbarkJS();
|
||||
// TODO add check to see if we need to start process
|
||||
this.startProcess(() => {});
|
||||
|
||||
|
||||
this.registerUploadCommand();
|
||||
|
||||
this._checkService((err) => {
|
||||
if (!err) {
|
||||
return;
|
||||
}
|
||||
self.logger.info("Swarm node not found, attempting to start own node");
|
||||
self.startProcess(() => {});
|
||||
// swarm needs geth to be running first
|
||||
this.events.once(constants.blockchain.blockchainReady, () => {
|
||||
this.swarm.isAvailable((err, isAvailable) => {
|
||||
if (err) return this.logger.error('Error checking swarm availability', err);
|
||||
if (isAvailable) {
|
||||
this.logger.info("Swarm node found, using currently running node");
|
||||
return;
|
||||
}
|
||||
this.logger.info("SWARM: Swarm node not found, attempting to start own node");
|
||||
return this.startProcess(() => {});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -54,15 +61,15 @@ class Swarm {
|
|||
self.logger.info(__('Swarm node is offline...'));
|
||||
});
|
||||
|
||||
self.events.request("services:register", 'Swarm', function(cb){
|
||||
self.events.request("services:register", 'Swarm', function (cb) {
|
||||
self.logger.trace(`Checking Swarm availability on ${self.providerUrl}...`);
|
||||
self._checkService((err, result) => {
|
||||
if (err) {
|
||||
self.logger.trace("Check Swarm availability error: " + err);
|
||||
return cb({name: "Swarm ", status: 'off'});
|
||||
}
|
||||
self.logger.trace("Swarm " + (result ? '':'on') + "available");
|
||||
return cb({name: "Swarm ", status: result ? 'on':'off'});
|
||||
self.logger.trace("Swarm " + (result ? '' : 'on') + "available");
|
||||
return cb({name: "Swarm ", status: result ? 'on' : 'off'});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -81,7 +81,7 @@
|
|||
"solc": "0.4.24",
|
||||
"string-replace-async": "^1.2.1",
|
||||
"style-loader": "^0.19.0",
|
||||
"swarmgw": "file:../swarmgw",
|
||||
"swarmjs": "file:../swarmjs",
|
||||
"tar": "^3.1.5",
|
||||
"toposort": "^1.0.0",
|
||||
"underscore": "^1.9.0",
|
||||
|
|
Loading…
Reference in New Issue