Skip to content

Commit

Permalink
Merge pull request #1502 from OriginTrail/hotfix/support-mariner-nodes
Browse files Browse the repository at this point in the history
Fix config reading for nodes with "mariner" node_env
  • Loading branch information
djordjekovac authored Mar 23, 2021
2 parents 2f60f47 + 0fa5521 commit 3017411
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'testnet';
}

const environmentConfig = global_config[process.env.NODE_ENV];
const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const environmentConfig = global_config[environment];
const blockchain_id = environmentConfig.blockchain.implementations[0].network_id;

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'testnet';
}

const environmentConfig = global_config[process.env.NODE_ENV];
const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const environmentConfig = global_config[environment];
const blockchain_id = environmentConfig.blockchain.implementations[0].network_id;

module.exports = {
Expand Down
6 changes: 5 additions & 1 deletion migrations/202011261243123-update-bids-add-blockchain-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'testnet';
}

const environmentConfig = global_config[process.env.NODE_ENV];
const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const environmentConfig = global_config[environment];
const blockchain_id = environmentConfig.blockchain.implementations[0].network_id;

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'testnet';
}

const environmentConfig = global_config[process.env.NODE_ENV];
const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const environmentConfig = global_config[environment];
const blockchain_id = environmentConfig.blockchain.implementations[0].network_id;

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ if (!process.env.NODE_ENV) {
// Environment not set. Use the production.
process.env.NODE_ENV = 'testnet';
}
const environmentConfig = global_config[process.env.NODE_ENV];

const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const environmentConfig = global_config[environment];
const blockchain_id = environmentConfig.blockchain.implementations[0].network_id;

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ if (!process.env.NODE_ENV) {
// Environment not set. Use the production.
process.env.NODE_ENV = 'testnet';
}
const environmentConfig = global_config[process.env.NODE_ENV];

const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const environmentConfig = global_config[environment];
const blockchain_id = environmentConfig.blockchain.implementations[0].network_id;

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ if (!process.env.NODE_ENV) {
// Environment not set. Use the production.
process.env.NODE_ENV = 'testnet';
}
const environmentConfig = global_config[process.env.NODE_ENV];

const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const environmentConfig = global_config[environment];
const blockchain_id = environmentConfig.blockchain.implementations[0].network_id;

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ if (!process.env.NODE_ENV) {
// Environment not set. Use the production.
process.env.NODE_ENV = 'testnet';
}
const environmentConfig = global_config[process.env.NODE_ENV];

const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const environmentConfig = global_config[environment];
const blockchain_id = environmentConfig.blockchain.implementations[0].network_id;

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ if (!process.env.NODE_ENV) {
// Environment not set. Use the production.
process.env.NODE_ENV = 'testnet';
}
const environmentConfig = global_config[process.env.NODE_ENV];

const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const environmentConfig = global_config[environment];
const blockchain_id = environmentConfig.blockchain.implementations[0].network_id;

module.exports = {
Expand Down
10 changes: 9 additions & 1 deletion modules/ImportUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ const OtJsonUtilities = require('./OtJsonUtilities');
const DataIntegrityResolver = require('./service/data-integrity/data-integrity-resolver');
// TODO Is this safe to read, IE will it always be the same,
// (could the node somehow change this in runtime? )
const defaultConfig = require('../config/config')[process.env.NODE_ENV];
if (!process.env.NODE_ENV) {
// Environment not set. Use the production.
process.env.NODE_ENV = 'testnet';
}
const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const defaultConfig = require('../config/config')[environment];

const data_constants = {
vertexType: {
Expand Down
11 changes: 10 additions & 1 deletion modules/OtJsonUtilities.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
const Utilities = require('./Utilities');
const { sha3_256 } = require('js-sha3');
const defaultConfig = require('../config/config')[process.env.NODE_ENV];

if (!process.env.NODE_ENV) {
// Environment not set. Use the production.
process.env.NODE_ENV = 'testnet';
}
const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const defaultConfig = require('../config/config')[environment];


class OtJsonUtilities {
Expand Down
10 changes: 9 additions & 1 deletion modules/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ require('winston-papertrail').Papertrail;
require('winston-loggly-bulk');
const util = require('util');

const runtimeConfigJson = require('../config/config.json')[process.env.NODE_ENV];
if (!process.env.NODE_ENV) {
// Environment not set. Use the production.
process.env.NODE_ENV = 'testnet';
}
const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const runtimeConfigJson = require('../config/config.json')[environment];

const colors = require('colors/safe');
const pjson = require('../package.json');
Expand Down
11 changes: 10 additions & 1 deletion modules/worker/export-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ const Utilities = require('../Utilities');
const ImportUtilities = require('../ImportUtilities');
const OtJsonUtilities = require('../OtJsonUtilities');
const fs = require('fs');
const defaultConfig = require('../../config/config')[process.env.NODE_ENV];

if (!process.env.NODE_ENV) {
// Environment not set. Use the production.
process.env.NODE_ENV = 'testnet';
}
const environment = process.env.NODE_ENV === 'mariner' ? 'mainnet' : process.env.NODE_ENV;
if (['mainnet', 'testnet', 'development'].indexOf(environment) < 0) {
throw Error(`Unsupported node environment ${environment}`);
}
const defaultConfig = require('../../config/config')[environment];

process.on('message', async (data) => {
const {
Expand Down

0 comments on commit 3017411

Please sign in to comment.