diff --git a/lib/worker.js b/lib/worker.js index 030d4ef..49c3680 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -92,7 +92,7 @@ function updateShareStats() { } break; } - if (Object.keys(localStats.miners).indexOf(minerID) >= 0) { + if (minerList.indexOf(minerID) >= 0) { localStats.miners[minerID] += share.shares; if (localTimes.miners[minerID] < share.timestamp) { localTimes.miners[minerID] = share.timestamp; @@ -104,7 +104,7 @@ function updateShareStats() { localTimes.miners[minerID] = share.timestamp; minerList.push(minerID); } - if (Object.keys(localStats.miners).indexOf(minerIDWithIdentifier) >= 0) { + if (minerList.indexOf(minerIDWithIdentifier) >= 0) { localStats.miners[minerIDWithIdentifier] += share.shares; if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) { localTimes.miners[minerIDWithIdentifier] = share.timestamp; @@ -247,27 +247,23 @@ function updateShareStats() { } function updatePoolStats(poolType) { + let cache; + if (typeof(poolType) !== 'undefined') { + cache = global.database.getCache(poolType + "_stats"); + } + cache = global.database.getCache("global_stats"); async.series([ function (callback) { debug(threadName + "Checking Influx for last 10min avg for pool stats"); - if (typeof(poolType) !== 'undefined') { - return callback(null, global.database.getCache(poolType + "_stats").hash || 0); - } - return callback(null, global.database.getCache("global_stats").hash || 0); + return callback(null, cache.hash || 0); }, function (callback) { debug(threadName + "Checking Influx for last 10min avg for miner count for pool stats"); - if (typeof(poolType) !== 'undefined') { - return callback(null, global.database.getCache(poolType + "_stats").minerCount || 0); - } - return callback(null, global.database.getCache("global_stats").minerCount || 0); + return callback(null, cache.minerCount || 0); }, function (callback) { debug(threadName + "Checking Influx for last 10min avg for miner count for pool stats"); - if (typeof(poolType) !== 'undefined') { - return callback(null, global.database.getCache(poolType + "_stats").totalHashes || 0); - } - return callback(null, global.database.getCache("global_stats").totalHashes || 0); + return callback(null, cache.totalHashes || 0); }, function (callback) { debug(threadName + "Checking MySQL for last block find time for pool stats"); @@ -319,10 +315,7 @@ function updatePoolStats(poolType) { }, function (callback) { debug(threadName + "Checking Influx for last 10min avg for miner count for pool stats"); - if (typeof(poolType) !== 'undefined') { - return callback(null, global.database.getCache(poolType + "_stats").roundHashes || 0); - } - return callback(null, global.database.getCache("global_stats").roundHashes || 0); + return callback(null, cache.roundHashes || 0); } ], function (err, result) { if (typeof(poolType) === 'undefined') {