fixup! Bugfix: Hashrate incorrect

This commit is contained in:
joshuayabut 2016-12-26 00:35:40 +00:00
parent c640b4fbaf
commit c83ed07049
2 changed files with 12 additions and 14 deletions

View File

@ -271,14 +271,12 @@ module.exports = function(logger, portalConfig, poolConfigs){
}; };
this.getReadableHashRateString = function(hashrate){ this.getReadableHashRateString = function(hashrate){
var i = -1; if (hashrate === 0)
var byteUnits = [ ' Sol',' KSol', ' MSol', ' GSol', ' TSol', ' PSol' ]; return '0 Sol';
do { var byteUnits = [ ' Sol', ' KSol', ' MSol', ' GSol', ' TSol', ' PSol' ];
hashrate = (hashrate * 2) / 1000000; hashrate = (hashrate * 2);
i++; var i = Math.floor((Math.log(hashrate/1000) / Math.log(1000)) - 1);
} while (hashrate > 1000); hashrate = (hashrate/1000) / Math.pow(1000, i + 1);
return hashrate.toFixed(2) + byteUnits[i]; return hashrate.toFixed(2) + byteUnits[i];
}; };
}; };

View File

@ -69,12 +69,12 @@ function buildChartData(){
} }
function getReadableHashRateString(hashrate){ function getReadableHashRateString(hashrate){
var i = -1; if (hashrate === 0)
var byteUnits = [ ' Sol',' KSol', ' MSol', ' GSol', ' TSol', ' PSol' ]; return '0 Sol';
do { var byteUnits = [ ' Sol', ' KSol', ' MSol', ' GSol', ' TSol', ' PSol' ];
hashrate = (hashrate * 2) / 1000000; hashrate = (hashrate * 2);
i++; var i = Math.floor((Math.log(hashrate/1000) / Math.log(1000)) - 1);
} while (hashrate > 1000); hashrate = (hashrate/1000) / Math.pow(1000, i + 1);
return Math.round(hashrate) + byteUnits[i]; return Math.round(hashrate) + byteUnits[i];
} }