mirror of https://github.com/BTCPrivate/z-nomp.git
added human readable auto-scaling hash rate strings to stats
This commit is contained in:
parent
df5ed6d29b
commit
5918baac2f
|
@ -144,7 +144,8 @@ module.exports = function(logger, portalConfig, poolConfigs){
|
|||
if (!portalStats.algos.hasOwnProperty(algo)){
|
||||
portalStats.algos[algo] = {
|
||||
workers: 0,
|
||||
hashrate: 0
|
||||
hashrate: 0,
|
||||
hashrateString: null
|
||||
};
|
||||
}
|
||||
portalStats.algos[algo].hashrate += coinStats.hashrate;
|
||||
|
@ -152,6 +153,11 @@ module.exports = function(logger, portalConfig, poolConfigs){
|
|||
|
||||
delete coinStats.hashrates;
|
||||
delete coinStats.shares;
|
||||
coinStats.hashrateString = _this.getReadableHashRateString(coinStats.hashrate);
|
||||
});
|
||||
|
||||
Object.keys(portalStats.algos).forEach(function(algo){
|
||||
algo.hashrateString = _this.getReadableHashRateString(algo.hashrate);
|
||||
});
|
||||
|
||||
_this.stats = portalStats;
|
||||
|
@ -160,5 +166,16 @@ module.exports = function(logger, portalConfig, poolConfigs){
|
|||
});
|
||||
|
||||
};
|
||||
|
||||
this.getReadableHashRateString = function(hashrate){
|
||||
var i = -1;
|
||||
var byteUnits = [' KH', ' MH', ' GH', ' TH', 'PH' ];
|
||||
do {
|
||||
hashrate = hashrate / 1024;
|
||||
i++;
|
||||
} while (hashrate > 1024);
|
||||
return hashrate.toFixed(2) + byteUnits[i];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue