Moving away from .keys to my already-available index. I am a spoon.

This commit is contained in:
Alexander Blair
2017-02-15 19:01:08 -08:00
parent becaf9424a
commit 603f56c743
+11 -18
View File
@@ -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') {