fancoder / cryptonote-universal-pool

Mining pool for all CryptoNote based coins such as Bytecoin, duckNote, Monero, and Fantomcoin.
http://cryptonotemining.org
GNU General Public License v2.0
335 stars 308 forks source link

getReadableHashrateString #110

Open CerveloFellow opened 6 years ago

CerveloFellow commented 6 years ago

On my admin userlist page, the readable hashrate was showing all of the array indices with the existing algorithm. So for example 1.24 KH/s would display as 1.24 h/s Kh/s Mh/s Gh/s Th/s Ph/s

I changed the function in api.js to this and got better results.

I'm not real familiar with git, otherwise I would have done a pull request with these changes.

function getReadableHashRateString(hashrate){ var displayrate = ["", "k", "M", "G", "T", "P"]; if(hashRate == 0) return '0 '; var k = 1024, i = Math.floor(Math.log(hashRate) / Math.log(k)); return parseFloat((hashRate/ Math.pow(k, i)).toFixed(2)) + ' ' + displayrate[i]; }