From 89945fff425b2dba366e84d2520391ad76f81fc7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jun 2018 13:18:28 +0200 Subject: [PATCH] Connection Strings replaced by User Profile --- BlobStorage.js | 6 ++++-- Run.js | 21 ++++++++++++++++++--- TradingBotProcessMainLoop.js | 2 ++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/BlobStorage.js b/BlobStorage.js index 6f9ee7342..0a941741e 100644 --- a/BlobStorage.js +++ b/BlobStorage.js @@ -44,13 +44,15 @@ exports.newBlobStorage = function newBlobStorage(BOT, logger) { if (FULL_LOG === true && logger !== undefined) { logger.write(MODULE_NAME, "[INFO] initialize -> environment = " + environment); } if (FULL_LOG === true && logger !== undefined) { logger.write(MODULE_NAME, "[INFO] initialize -> containerName = " + containerName); } - let readConnectionString = global.STORAGE_PERMISSIONS[environment][containerName].readConnectionString; + + + let readConnectionString = global.USER_PROFILE.storagePermissions.get(pDataOwner + "." + "READ"); if (readConnectionString !== undefined) { readOnlyBlobService = storage.createBlobService(readConnectionString); } - let writeConnectionString = global.STORAGE_PERMISSIONS[environment][containerName].writeConnectionString; + let writeConnectionString = global.USER_PROFILE.storagePermissions.get(pDataOwner + "." + "WRITE"); if (writeConnectionString !== undefined) { writeOnlyBlobService = storage.createBlobService(writeConnectionString); diff --git a/Run.js b/Run.js index f8063d501..b4789a665 100644 --- a/Run.js +++ b/Run.js @@ -29,7 +29,7 @@ process.on('exit', function (code) { } }); -global.STORAGE_PERMISSIONS = {}; +global.USER_PROFILE = {}; readStoragePermissions(); @@ -39,8 +39,23 @@ function readStoragePermissions() { try { let fs = require('fs'); - filePath = '../' + 'Connection-Strings' + '/' + 'Storage.Permissions.json'; - global.STORAGE_PERMISSIONS = JSON.parse(fs.readFileSync(filePath, 'utf8')); + filePath = '../' + 'User-Profile' + '/' + 'User.Profile.json'; + global.USER_PROFILE = JSON.parse(fs.readFileSync(filePath, 'utf8')); + + + /* Here we will rearrange the storage permissions array into a map, so that it can be easily consumed when needed. */ + + let permissionsMap = new Map; + + for (i = 0; i < global.USER_PROFILE.storagePermissions.length; i++) { + + let permission = global.USER_PROFILE.storagePermissions[i]; + + permissionsMap.set(permission[0], permission[1]); + + } + + global.USER_PROFILE.storagePermissions = permissionsMap; readExchangeAPIKey(); } diff --git a/TradingBotProcessMainLoop.js b/TradingBotProcessMainLoop.js index 36f4f48c3..e537e8244 100644 --- a/TradingBotProcessMainLoop.js +++ b/TradingBotProcessMainLoop.js @@ -946,6 +946,8 @@ function checkLoopHealth(pLastLoop) { + if (bot.startMode === 'Backtest') { return;} + if (bot.loopCounter <= pLastLoop + 1) { // This means that the next loop started but also stopped executing abruptally. let now = new Date().valueOf();