add config to specify available providers for each component

This commit is contained in:
Iuri Matias 2017-02-28 21:43:03 -05:00
parent 09e58977e4
commit 1674adee4a
7 changed files with 18 additions and 6 deletions

View File

@ -1,6 +1,7 @@
{ {
"default": { "default": {
"enabled": true, "enabled": true,
"provider": "whisper" "provider": "whisper",
"available_providers": ["whisper", "orbit"]
} }
} }

View File

@ -3,6 +3,7 @@
"enabled": true, "enabled": true,
"ipfs_bin": "ipfs", "ipfs_bin": "ipfs",
"provider": "ipfs", "provider": "ipfs",
"available_providers": ["ipfs"],
"host": "localhost", "host": "localhost",
"port": 5001 "port": 5001
}, },

View File

@ -1,6 +1,7 @@
{ {
"default": { "default": {
"enabled": true, "enabled": true,
"provider": "whisper" "provider": "whisper",
"available_providers": ["whisper", "orbit"]
} }
} }

View File

@ -3,6 +3,7 @@
"enabled": true, "enabled": true,
"ipfs_bin": "ipfs", "ipfs_bin": "ipfs",
"provider": "ipfs", "provider": "ipfs",
"available_providers": ["ipfs"],
"host": "localhost", "host": "localhost",
"port": 5001 "port": 5001
}, },

View File

@ -114,6 +114,9 @@ Config.prototype.loadStorageConfigFile = function() {
if (this.storageConfig.enabled === undefined) { if (this.storageConfig.enabled === undefined) {
this.storageConfig.enabled = true; this.storageConfig.enabled = true;
} }
if (this.storageConfig.available_providers === undefined) {
this.storageConfig.available_providers = [];
}
}; };
Config.prototype.loadCommunicationConfigFile = function() { Config.prototype.loadCommunicationConfigFile = function() {
@ -139,6 +142,9 @@ Config.prototype.loadCommunicationConfigFile = function() {
if (this.communicationConfig.enabled === undefined) { if (this.communicationConfig.enabled === undefined) {
this.communicationConfig.enabled = true; this.communicationConfig.enabled = true;
} }
if (this.communicationConfig.available_providers === undefined) {
this.communicationConfig.available_providers = [];
}
}; };
Config.prototype.loadEmbarkConfigFile = function() { Config.prototype.loadEmbarkConfigFile = function() {
@ -181,15 +187,15 @@ Config.prototype.loadFiles = function(files) {
}).filter(function(file) { }).filter(function(file) {
if (file === 'embark.js') { if (file === 'embark.js') {
if (self.blockchainConfig.enabled || self.communicationConfig.provider === 'whisper') { if (self.blockchainConfig.enabled || self.communicationConfig.provider === 'whisper' || self.communicationConfig.available_providers.indexOf('whisper') >= 0) {
readFiles.push({filename: 'web3.js', content: fs.readFileSync(fs.embarkPath("js/web3.js")).toString(), path: fs.embarkPath("js/web3.js")}); readFiles.push({filename: 'web3.js', content: fs.readFileSync(fs.embarkPath("js/web3.js")).toString(), path: fs.embarkPath("js/web3.js")});
} }
if (self.storageConfig.enabled && self.storageConfig.provider === 'ipfs') { if (self.storageConfig.enabled && (self.storageConfig.provider === 'ipfs' || self.storageConfig.available_providers.indexOf('ipfs') >= 0)) {
readFiles.push({filename: 'ipfs.js', content: fs.readFileSync(fs.embarkPath("js/ipfs.js")).toString(), path: fs.embarkPath("js/ipfs.js")}); readFiles.push({filename: 'ipfs.js', content: fs.readFileSync(fs.embarkPath("js/ipfs.js")).toString(), path: fs.embarkPath("js/ipfs.js")});
} }
if (self.communicationConfig.enabled && self.communicationConfig.provider === 'orbit') { if (self.communicationConfig.enabled && (self.communicationConfig.provider === 'orbit' || self.communicationConfig.available_providers.indexOf('orbit') >= 0)) {
// TODO: remove duplicated files if functionality is the same for storage and orbit // TODO: remove duplicated files if functionality is the same for storage and orbit
readFiles.push({filename: 'ipfs-api.js', content: fs.readFileSync(fs.embarkPath("js/ipfs-api.min.js")).toString(), path: fs.embarkPath("js/ipfs-api.min.js")}); readFiles.push({filename: 'ipfs-api.js', content: fs.readFileSync(fs.embarkPath("js/ipfs-api.min.js")).toString(), path: fs.embarkPath("js/ipfs-api.min.js")});
readFiles.push({filename: 'orbit.js', content: fs.readFileSync(fs.embarkPath("js/orbit.min.js")).toString(), path: fs.embarkPath("js/orbit.min.js")}); readFiles.push({filename: 'orbit.js', content: fs.readFileSync(fs.embarkPath("js/orbit.min.js")).toString(), path: fs.embarkPath("js/orbit.min.js")});

View File

@ -1,6 +1,7 @@
{ {
"default": { "default": {
"enabled": true, "enabled": true,
"provider": "whisper" "provider": "whisper",
"available_providers": ["whisper", "orbit"]
} }
} }

View File

@ -1,6 +1,7 @@
{ {
"default": { "default": {
"enabled": true, "enabled": true,
"available_providers": ["ipfs"],
"ipfs_bin": "ipfs", "ipfs_bin": "ipfs",
"provider": "ipfs", "provider": "ipfs",
"host": "localhost", "host": "localhost",