From 8ffc9b89e273e91018ac715858e5ba392acbff94 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Thu, 13 Sep 2018 13:37:44 +0100 Subject: [PATCH] Swarm use local data dir --- lib/modules/blockchain_process/blockchain.js | 2 +- lib/modules/storage/storageProcessesLauncher.js | 1 + lib/modules/swarm/process.js | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/modules/blockchain_process/blockchain.js b/lib/modules/blockchain_process/blockchain.js index 7f8ecaf2b..d4edb6a30 100644 --- a/lib/modules/blockchain_process/blockchain.js +++ b/lib/modules/blockchain_process/blockchain.js @@ -64,7 +64,7 @@ var Blockchain = function(options) { this.config.account = {}; this.config.account.password = fs.embarkPath("templates/boilerplate/config/development/password"); this.config.genesisBlock = fs.embarkPath("templates/boilerplate/config/development/genesis.json"); - this.config.datadir = fs.embarkPath(".embark/development/datadir"); + this.config.datadir = fs.dappPath(".embark/development/datadir"); } const spaceMessage = 'The path for %s in blockchain config contains spaces, please remove them'; diff --git a/lib/modules/storage/storageProcessesLauncher.js b/lib/modules/storage/storageProcessesLauncher.js index 5f7a0156c..79b9a3b8c 100644 --- a/lib/modules/storage/storageProcessesLauncher.js +++ b/lib/modules/storage/storageProcessesLauncher.js @@ -113,6 +113,7 @@ class StorageProcessesLauncher { self.processes[storageName].send({ action: constants.blockchain.init, options: { storageConfig: self.storageConfig, + blockchainConfig: self.blockchainConfig, cors: self.buildCors(storageName) } }); diff --git a/lib/modules/swarm/process.js b/lib/modules/swarm/process.js index 2ecf29d9c..4376a9919 100644 --- a/lib/modules/swarm/process.js +++ b/lib/modules/swarm/process.js @@ -9,6 +9,7 @@ class SwarmProcess extends ProcessWrapper { constructor(options) { super(); this.storageConfig = options.storageConfig; + this.blockchainConfig = options.blockchainConfig; this.cors = options.cors; this.command = this.storageConfig.swarmPath || 'swarm'; } @@ -19,11 +20,14 @@ class SwarmProcess extends ProcessWrapper { return 'Account address and password are needed in the storage config to start the Swarm process'; } + const datadir = this.blockchainConfig.datadir || fs.dappPath(`.embark/development/datadir`); const args = [ - `--bzzaccount=${this.storageConfig.account.address}`, - `--password=${fs.dappPath(this.storageConfig.account.password)}`, - `--corsdomain=${self.cors.join(',')}` - ]; + '--datadir', datadir, + '--bzzaccount', this.storageConfig.account.address, + '--password', fs.dappPath(this.storageConfig.account.password), + '--corsdomain', self.cors.join(',') + ]; + console.trace('Starting swarm process with arguments: ' + args.join(' ')); this.child = child_process.spawn(this.command, args);