Browse Source

php - sort user workers by hash rate

master
kanoi 10 years ago
parent
commit
9ce3aafc5c
  1. 61
      pool/page_workers.php

61
pool/page_workers.php

@ -15,9 +15,14 @@ function worktitle($data, $user)
return $pg; return $pg;
} }
# #
function workhashorder($a, $b)
{
return $b['w_uhr'] - $a['w_uhr'];
}
#
function workuser($data, $user, &$offset, &$totshare, &$totdiff, function workuser($data, $user, &$offset, &$totshare, &$totdiff,
&$totinvalid, &$totrate, &$blockacc, &$totinvalid, &$totrate, &$blockacc,
&$blockreward, $old = false) &$blockreward, $old = false, $srt = false)
{ {
$ans = getWorkers($user); $ans = getWorkers($user);
@ -28,6 +33,7 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff,
$blockacc = $ans['blockacc']; $blockacc = $ans['blockacc'];
if (isset($ans['blockreward'])) if (isset($ans['blockreward']))
$blockreward = $ans['blockreward']; $blockreward = $ans['blockreward'];
$all = array();
$count = $ans['rows']; $count = $ans['rows'];
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++)
{ {
@ -35,48 +41,69 @@ function workuser($data, $user, &$offset, &$totshare, &$totdiff,
if ($old !== false && $lst > $old) if ($old !== false && $lst > $old)
continue; continue;
if ($ans['w_elapsed:'.$i] > 3600)
$uhr = $ans['w_hashrate1hr:'.$i];
else
$uhr = $ans['w_hashrate5m:'.$i];
$all[] = array('workername' => $ans['workername:'.$i],
'w_lastshare' => $ans['w_lastshare:'.$i],
'w_lastdiff' => $ans['w_lastdiff:'.$i],
'w_shareacc' => $ans['w_shareacc:'.$i],
'w_diffacc' => $ans['w_diffacc:'.$i],
'w_diffinv' => $ans['w_diffinv:'.$i],
'w_lastdiff' => $ans['w_lastdiff:'.$i],
'w_uhr' => $uhr);
}
if ($srt)
usort($all, 'workhashorder');
for ($i = 0; $i < $count; $i++)
{
$lst = $ans['STAMP'] - $all[$i]['w_lastshare'];
if ($old !== false && $lst > $old)
continue;
if ((($offset) % 2) == 0) if ((($offset) % 2) == 0)
$row = 'even'; $row = 'even';
else else
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= '<td class=dl>'.htmlspecialchars($ans['workername:'.$i]).'</td>'; $pg .= '<td class=dl>'.htmlspecialchars($all[$i]['workername']).'</td>';
if ($ans['w_lastdiff:'.$i] > 0) if ($all[$i]['w_lastdiff'] > 0)
$ld = difffmt($ans['w_lastdiff:'.$i]); $ld = difffmt($all[$i]['w_lastdiff']);
else else
$ld = '&nbsp;'; $ld = '&nbsp;';
$pg .= "<td class=dr>$ld</td>"; $pg .= "<td class=dr>$ld</td>";
$pg .= '<td class=dr>'.howlongago($lst).'</td>'; $pg .= '<td class=dr>'.howlongago($lst).'</td>';
$shareacc = number_format($ans['w_shareacc:'.$i], 0); $shareacc = number_format($all[$i]['w_shareacc'], 0);
$totshare += $ans['w_shareacc:'.$i]; $totshare += $all[$i]['w_shareacc'];
$diffacc = number_format($ans['w_diffacc:'.$i], 0); $diffacc = number_format($all[$i]['w_diffacc'], 0);
$totdiff += $ans['w_diffacc:'.$i]; $totdiff += $all[$i]['w_diffacc'];
$pg .= "<td class=dr>$shareacc</td>"; $pg .= "<td class=dr>$shareacc</td>";
$pg .= "<td class=dr>$diffacc</td>"; $pg .= "<td class=dr>$diffacc</td>";
$dtot = $ans['w_diffacc:'.$i] + $ans['w_diffinv:'.$i]; $dtot = $all[$i]['w_diffacc'] + $all[$i]['w_diffinv'];
if ($dtot > 0) if ($dtot > 0)
$rej = number_format(100.0 * $ans['w_diffinv:'.$i] / $dtot, 3); $rej = number_format(100.0 * $all[$i]['w_diffinv'] / $dtot, 3);
else else
$rej = '0'; $rej = '0';
$totinvalid += $ans['w_diffinv:'.$i]; $totinvalid += $all[$i]['w_diffinv'];
$pg .= "<td class=dr>$rej%</td>"; $pg .= "<td class=dr>$rej%</td>";
if ($blockacc <= 0) if ($blockacc <= 0)
$blkpct = '&nbsp;'; $blkpct = '&nbsp;';
else else
$blkpct = number_format(100.0 * $ans['w_diffacc:'.$i] / $blockacc, 3) . '%'; $blkpct = number_format(100.0 * $all[$i]['w_diffacc'] / $blockacc, 3) . '%';
$pg .= "<td class=dr>$blkpct</td>"; $pg .= "<td class=dr>$blkpct</td>";
if ($ans['w_elapsed:'.$i] > 3600) $uhr = $all[$i]['w_uhr'];
$uhr = $ans['w_hashrate1hr:'.$i];
else
$uhr = $ans['w_hashrate5m:'.$i];
if ($uhr == '?') if ($uhr == '?')
$uhr = '?GHs'; $uhr = '?GHs';
else else
@ -138,7 +165,7 @@ function doworker($data, $user)
$pg .= worktitle($data, $user); $pg .= worktitle($data, $user);
$pg .= workuser($data, $user, $offset, $totshare, $totdiff, $totinvalid, $pg .= workuser($data, $user, $offset, $totshare, $totdiff, $totinvalid,
$totrate, $blockacc, $blockreward, false); $totrate, $blockacc, $blockreward, false, true);
$pg .= worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate, $pg .= worktotal($offset, $totshare, $totdiff, $totinvalid, $totrate,
$blockacc, $blockreward); $blockacc, $blockreward);

Loading…
Cancel
Save