From 6b12b64bd436f09c52f5465545d05b7d38792a0e Mon Sep 17 00:00:00 2001 From: Petr Balashov Date: Thu, 23 Mar 2017 13:09:44 +0100 Subject: [PATCH] minor changes to cache.js --- routes/cache.js | 8 ++++---- routes/mock.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/routes/cache.js b/routes/cache.js index 1f94418..c1b7b41 100644 --- a/routes/cache.js +++ b/routes/cache.js @@ -316,7 +316,7 @@ cache.one = function(req, res, next) { }); function execDEXRequests(address, coin) { - var dexUrls = { + let dexUrls = { 'listunspent': 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/dex/listunspent?userpass=' + sessionKey + '&symbol=' + coin + '&address=' + address, 'listtransactions': 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/dex/listtransactions?userpass=' + sessionKey + '&count=100&skip=0&symbol=' + coin + '&address=' + address, 'getbalance': 'http://' + cache.appConfig.host + ':' + cache.appConfig.iguanaCorePort + '/api/dex/getbalance?userpass=' + sessionKey + '&symbol=' + coin + '&address=' + address, @@ -327,17 +327,17 @@ cache.one = function(req, res, next) { for (var a = 0; a < callsArray.length; a++) { _dexUrls[callsArray[a]] = dexUrls[callsArray[a]]; } + if (coin === 'BTC' || coin === 'SYS') { delete _dexUrls.refresh; delete _dexUrls.getbalance; } - //console.log(JSON.stringify(dexUrls)); + console.log(coin + ' address ' + address); if (!outObj.basilisk[coin][address]) { outObj.basilisk[coin][address] = {}; writeCache(); } - console.log(_dexUrls); // set current call status async.forEachOf(_dexUrls, function(dexUrl, key) { @@ -421,7 +421,7 @@ cache.one = function(req, res, next) { writeCache(); } - if (error) { + if (error || !body || !response) { outObj.basilisk[coin][address][key] = {}; outObj.basilisk[coin][address][key].data = { 'error': 'request failed' }; outObj.basilisk[coin][address][key].timestamp = 1471620867 // add timestamp diff --git a/routes/mock.js b/routes/mock.js index 0a87045..39e4156 100644 --- a/routes/mock.js +++ b/routes/mock.js @@ -28,8 +28,8 @@ mock.get = function(req, res, next) { } if (_url.indexOf('/api/dex/listunspent') > -1 || _url.indexOf('/api/dex/listtransactions') > -1 || - _url.indexOf('/api/basilisk/getbalance') > -1 || - _url.indexOf('/api/dex/refresh') > -1) { + _url.indexOf('/api/ss/getbalance') > -1 || + _url.indexOf('/api/ww/refresh') > -1) { res.end(JSON.stringify({ 'some key': 'some value' }));