Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better readable network difficulty + correct readable hash rate calculation #43

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function getPublicPorts(ports){

function getReadableHashRateString(hashrate){
var i = 0;
var byteUnits = [' H', ' KH', ' MH', ' GH', ' TH', ' PH' ];
var byteUnits = [' H', ' kH', ' MH', ' GH', ' TH', ' PH', ' EH', ' ZH', ' YH' ];
while (hashrate > 1000){
hashrate = hashrate / 1000;
i++;
Expand Down
2 changes: 1 addition & 1 deletion website/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
function getReadableHashRateString(hashrate) {
hashrate = hashrate || 0;
var i = 0;
var byteUnits = [' H', ' KH', ' MH', ' GH', ' TH', ' PH' ];
var byteUnits = [' H', ' kH', ' MH', ' GH', ' TH', ' PH', ' EH', ' ZH', ' YH' ];
while(hashrate > 1000) {
hashrate = hashrate / 1000;
i++;
Expand Down
3 changes: 2 additions & 1 deletion website/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ var networkStat = {
["krb.sberex.com", "http://krb.sberex.com:7006"],
["krb.crypto-coins.club", "http://krb.crypto-coins.club:8118"],
["krb.cryptonotepool.com", "http://5.189.135.137:8618"],
["krbpool.ml", "http://krbpool.ml:8117"]
["krbpool.ml", "http://krbpool.ml:8117"],
["mine4all.pp.ua", "http://mine4all.pp.ua:8877"]
],
"qcn": [
["qcn.mypool.online", "http://qcn.mypool.online:23084"]
Expand Down
13 changes: 12 additions & 1 deletion website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,25 @@

function getReadableHashRateString(hashrate){
var i = 0;
var byteUnits = [' H', ' KH', ' MH', ' GH', ' TH', ' PH' ];
var byteUnits = [' H', ' kH', ' MH', ' GH', ' TH', ' PH', ' EH', ' ZH', ' YH' ];
while (hashrate > 1000){
hashrate = hashrate / 1000;
i++;
}
return hashrate.toFixed(2) + byteUnits[i];
}

function getReadableDifficultyString(difficulty){
if (difficulty < 1000) return difficulty.toString();
var i = 0;
var byteUnits = [' ', ' K', ' M', ' G', ' T', ' P', ' E', ' Z', ' Y' ];
while (difficulty > 1000){
difficulty = difficulty / 1000;
i++;
}
return difficulty.toFixed(2) + byteUnits[i];
}

function formatBlockLink(hash){
return '<a href="' + getBlockchainUrl(hash) + '">' + hash + '</a>';
}
Expand Down
2 changes: 1 addition & 1 deletion website/pages/blockchain_blocks.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
update: function(){
updateText('networkLastReward', lastStats.network.height.toString());
updateText('networkHashrate', getReadableHashRateString(lastStats.network.difficulty / lastStats.config.coinDifficultyTarget) + '/sec');
updateText('networkDifficulty', lastStats.network.difficulty.toString());
updateText('networkDifficulty', getReadableDifficultyString(lastStats.network.difficulty));
renderInitialBlocks();
}
};
Expand Down
6 changes: 3 additions & 3 deletions website/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ <h3>Estimate Mining Profits</h3>
<input type="number" class="form-control" id="calcHashRate" placeholder="Enter Your Hash Rate">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="calcHashDropdown">
<span id="calcHashUnit" data-mul="1">KH/s</span> <span class="caret"></span>
<span id="calcHashUnit" data-mul="1">kH/s</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right" role="menu" id="calcHashUnits">
<li><a href="#" data-mul="0">H/s</a></li>
<li><a href="#" data-mul="1">KH/s</a></li>
<li><a href="#" data-mul="1">kH/s</a></li>
<li><a href="#" data-mul="2">MH/s</a></li>
</ul>
</div>
Expand Down Expand Up @@ -317,7 +317,7 @@ <h4 class="yourStats">Payments</h4>
$('#networkLastBlockFound').timeago('update', new Date(lastStats.network.timestamp * 1000).toISOString());

updateText('networkHashrate', getReadableHashRateString(lastStats.network.difficulty / lastStats.config.coinDifficultyTarget) + '/sec');
updateText('networkDifficulty', lastStats.network.difficulty.toString());
updateText('networkDifficulty', getReadableDifficultyString(lastStats.network.difficulty));
updateText('blockchainHeight', lastStats.network.height.toString());
updateText('networkLastReward', getReadableCoins(lastStats.network.reward, 4));
updateText('lastHash', lastStats.network.hash.substr(0, 13) + '...').setAttribute('href', getBlockchainUrl(lastStats.network.hash));
Expand Down