Browse Source

miner.php highlighting correctly handling difficulty

nfactor-troky
Kano 12 years ago
parent
commit
22a8eee0b8
  1. 39
      miner.php

39
miner.php

@ -523,7 +523,15 @@ function classlastshare($when, $alldata, $warnclass, $errorclass)
if (!isset($alldata['Last Share Time'])) if (!isset($alldata['Last Share Time']))
return ''; return '';
if (!isset($alldata['Last Share Difficulty']))
return '';
$expected = pow(2, 32) / ($alldata['MHS av'] * pow(10, 6)); $expected = pow(2, 32) / ($alldata['MHS av'] * pow(10, 6));
// If the share difficulty changes while waiting on a share,
// this calculation will of course be incorrect
$expected *= $alldata['Last Share Difficulty'];
$howlong = $when - $alldata['Last Share Time']; $howlong = $when - $alldata['Last Share Time'];
if ($howlong < 1) if ($howlong < 1)
$howlong = 1; $howlong = 1;
@ -658,11 +666,20 @@ function fmt($section, $name, $value, $when, $alldata)
if ($value == 0) if ($value == 0)
$class = $errorclass; $class = $errorclass;
else else
if (isset($alldata['MHS av'])) if (isset($alldata['Difficulty Accepted'])
&& isset($alldata['Accepted'])
&& isset($alldata['MHS av'])
&& ($alldata['Difficulty Accepted'] > 0)
&& ($alldata['Accepted'] > 0))
{ {
$expected = 60 * $alldata['MHS av'] * (pow(10, 6) / pow(2, 32)); $expected = 60 * $alldata['MHS av'] * (pow(10, 6) / pow(2, 32));
if ($expected == 0) if ($expected == 0)
$expected = 0.000001; // 1 H/s $expected = 0.000001; // 1 H/s
$da = $alldata['Difficulty Accepted'];
$a = $alldata['Accepted'];
$expected /= ($da / $a);
$ratio = $value / $expected; $ratio = $value / $expected;
if ($ratio < 0.9) if ($ratio < 0.9)
$class = $loclass; $class = $loclass;
@ -730,16 +747,26 @@ function fmt($section, $name, $value, $when, $alldata)
$dec = ''; $dec = '';
else else
$dec = '.'.$parts[1]; $dec = '.'.$parts[1];
$ret = number_format($parts[0]).$dec; $ret = number_format((float)$parts[0]).$dec;
if ($value == 0) if ($value == 0)
$class = $errorclass; $class = $errorclass;
else else
if (isset($alldata['Utility'])) if (isset($alldata['Difficulty Accepted'])
&& isset($alldata['Accepted'])
&& isset($alldata['Utility'])
&& ($alldata['Difficulty Accepted'] > 0)
&& ($alldata['Accepted'] > 0))
{ {
$expected = 60 * $value * (pow(10, 6) / pow(2, 32)); $expected = 60 * $value * (pow(10, 6) / pow(2, 32));
$utility = $alldata['Utility']; if ($expected == 0)
$ratio = $utility / $expected; $expected = 0.000001; // 1 H/s
$da = $alldata['Difficulty Accepted'];
$a = $alldata['Accepted'];
$expected /= ($da / $a);
$ratio = $alldata['Utility'] / $expected;
if ($ratio < 0.9) if ($ratio < 0.9)
$class = $hiclass; $class = $hiclass;
else else
@ -783,7 +810,7 @@ function fmt($section, $name, $value, $when, $alldata)
$dec = ''; $dec = '';
else else
$dec = '.'.$parts[1]; $dec = '.'.$parts[1];
$ret = number_format($parts[0]).$dec; $ret = number_format((float)$parts[0]).$dec;
break; break;
case 'GPU.Status': case 'GPU.Status':
case 'PGA.Status': case 'PGA.Status':

Loading…
Cancel
Save