get correct ipfs node depending on the config
This commit is contained in:
parent
8720f43e39
commit
c70e583557
|
@ -13,9 +13,6 @@ class IPFS {
|
||||||
this.events = embark.events;
|
this.events = embark.events;
|
||||||
this.buildDir = options.buildDir;
|
this.buildDir = options.buildDir;
|
||||||
this.storageConfig = embark.config.storageConfig;
|
this.storageConfig = embark.config.storageConfig;
|
||||||
this.host = options.host || this.storageConfig.upload.host;
|
|
||||||
this.port = options.port || this.storageConfig.upload.port;
|
|
||||||
this.protocol = options.protocol || this.storageConfig.upload.protocol;
|
|
||||||
this.embark = embark;
|
this.embark = embark;
|
||||||
|
|
||||||
this.webServerConfig = embark.config.webServerConfig
|
this.webServerConfig = embark.config.webServerConfig
|
||||||
|
@ -83,9 +80,23 @@ class IPFS {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getNodeUrl() {
|
||||||
|
if (this.storageConfig.upload.provider === 'ipfs') {
|
||||||
|
let { protocol, host, port } = this.storageConfig.upload.provider;
|
||||||
|
return (protocol || 'http') + '://' + host + ':' + port + '/api/v0/version';
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let connection of this.storageConfig.dappConnection) {
|
||||||
|
if (connection.provider === 'ipfs') {
|
||||||
|
let { protocol, host, port } = connection;
|
||||||
|
return (protocol || 'http') + '://' + host + ':' + port + '/api/v0/version';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_checkService(cb) {
|
_checkService(cb) {
|
||||||
const self = this;
|
const self = this;
|
||||||
let url = (self.protocol || 'http') + '://' + self.host + ':' + self.port + '/api/v0/version';
|
let url = this._getNodeUrl();
|
||||||
self.logger.info(`Checking IPFS version on ${url}...`);
|
self.logger.info(`Checking IPFS version on ${url}...`);
|
||||||
if (self.protocol !== 'https'){
|
if (self.protocol !== 'https'){
|
||||||
utils.httpGetJson(url, cb);
|
utils.httpGetJson(url, cb);
|
||||||
|
|
|
@ -31,6 +31,7 @@ class Storage {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
addSetProviders() {
|
addSetProviders() {
|
||||||
|
const self = this;
|
||||||
// filter list of dapp connections based on available_providers set in config
|
// filter list of dapp connections based on available_providers set in config
|
||||||
let hasSwarm = _.contains(this.storageConfig.available_providers, 'swarm'); // don't need to eval this in every loop iteration
|
let hasSwarm = _.contains(this.storageConfig.available_providers, 'swarm'); // don't need to eval this in every loop iteration
|
||||||
// contains valid dapp storage providers
|
// contains valid dapp storage providers
|
||||||
|
|
Loading…
Reference in New Issue