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:
emizzle 2018-09-05 16:07:30 +10:00
parent b5e8546ebd
commit fcb75dee11
3 changed files with 2544 additions and 1947 deletions

View File

@ -1,9 +1,10 @@
const UploadSwarm = require('./upload.js'); const UploadSwarm = require('./upload.js');
const utils = require('../../utils/utils.js'); const utils = require('../../utils/utils.js');
const fs = require('../../core/fs.js'); const fs = require('../../core/fs.js');
const SwarmGW = require('swarmgw'); const SwarmJS = require('swarmjs');
// TODO: not great, breaks module isolation // TODO: not great, breaks module isolation
const StorageProcessesLauncher = require('../storage/storageProcessesLauncher'); const StorageProcessesLauncher = require('../storage/storageProcessesLauncher');
const constants = require('../../constants.json');
class Swarm { class Swarm {
@ -26,20 +27,26 @@ class Swarm {
if (!this.isSwarmEnabledInTheConfig()) { if (!this.isSwarmEnabledInTheConfig()) {
return; return;
} }
this.swarm = new SwarmGW({gateway: this.providerUrl}); console.dir('STARTING SWARMJS');
this.swarm = new SwarmJS({gateway: this.providerUrl});
this.setServiceCheck(); this.setServiceCheck();
this.addProviderToEmbarkJS(); this.addProviderToEmbarkJS();
// TODO add check to see if we need to start process
this.startProcess(() => {});
this.registerUploadCommand(); this.registerUploadCommand();
this._checkService((err) => { // swarm needs geth to be running first
if (!err) { 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; return;
} }
self.logger.info("Swarm node not found, attempting to start own node"); this.logger.info("SWARM: Swarm node not found, attempting to start own node");
self.startProcess(() => {}); return this.startProcess(() => {});
});
}); });
} }

4456
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,7 @@
"solc": "0.4.24", "solc": "0.4.24",
"string-replace-async": "^1.2.1", "string-replace-async": "^1.2.1",
"style-loader": "^0.19.0", "style-loader": "^0.19.0",
"swarmgw": "file:../swarmgw", "swarmjs": "file:../swarmjs",
"tar": "^3.1.5", "tar": "^3.1.5",
"toposort": "^1.0.0", "toposort": "^1.0.0",
"underscore": "^1.9.0", "underscore": "^1.9.0",