Browse Source

php - block information

master
kanoi 8 years ago
parent
commit
8b3f5d3225
  1. 99
      pool/page_blocks.php

99
pool/page_blocks.php

@ -69,28 +69,12 @@ function pctcolour($pct)
return array($fg, $bg); return array($fg, $bg);
} }
# #
function doblocks($data, $user) function statstable($poolfee, $ans, $data)
{ {
$blink = '<a href=https://www.blocktrail.com/BTC/block/'; if ($ans['STATUS'] != 'ok' or !isset($ans['s_rows']) or $ans['s_rows'] < 1)
$poolfee = 0.9; # pool fee as a % out of 100 return '';
$pg = '';
if ($user === null)
$ans = getBlocks('Anon');
else
$ans = getBlocks($user);
if (nuem(getparam('csv', true)))
$wantcsv = false;
else
$wantcsv = true;
if ($wantcsv === false) $pg = '<h1>Block Statistics</h1>';
{
if ($ans['STATUS'] == 'ok' and isset($ans['s_rows']) and $ans['s_rows'] > 0)
{
$pg .= '<h1>Block Statistics</h1>';
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
$pg .= "<thead><tr class=title>"; $pg .= "<thead><tr class=title>";
$pg .= "<td class=dl>Description</td>"; $pg .= "<td class=dl>Description</td>";
@ -146,14 +130,22 @@ function doblocks($data, $user)
$pg .= "</tr>\n"; $pg .= "</tr>\n";
} }
$pg .= "</tbody></table>\n"; $pg .= "</tbody></table>\n";
} return $pg;
}
#
function monthtable($poolfee, $ans, $limit)
{
if ($ans['STATUS'] != 'ok' or !isset($ans['rows']) or $ans['rows'] < 1)
return '';
if ($ans['STATUS'] == 'ok' and isset($ans['rows']) and $ans['rows'] > 0) $nowmon = intval(gmdate('n', $ans['STAMP']));
{ $nowyyyy = intval(gmdate('Y', $ans['STAMP']));
$pg .= '<br><h1>Monthly Statistics</h1>';
$pg = '<h1>Monthly Statistics</h1>';
$pg .= "<table cellpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table cellpadding=0 cellspacing=0 border=0>\n";
$pg .= "<thead><tr class=title>"; $pg .= "<thead><tr class=title>";
$pg .= "<td class=dl>UTC Month</td>"; $pg .= "<td class=dl>UTC Month</td>";
$pg .= "<td class=dr>Pool Avg</td>";
$pg .= "<td class=dr>Blocks</td>"; $pg .= "<td class=dr>Blocks</td>";
$pg .= "<td class=dr>Expected</td>"; $pg .= "<td class=dr>Expected</td>";
$pg .= "<td class=dr>Mean Diff%</td>"; $pg .= "<td class=dr>Mean Diff%</td>";
@ -164,7 +156,7 @@ function doblocks($data, $user)
$pg .= '<tbody>'; $pg .= '<tbody>';
$count = $ans['rows']; $count = $ans['rows'];
$rout = $bcount = $bcd = $bmon = $byyyy = $bdiffratio = $btxn = 0; $rout = $bcount = $bcd = $bmon = $byyyy = $bdiffacc = $bdiffratio = $btxn = 0;
$skipped = false; $skipped = false;
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++)
{ {
@ -194,36 +186,50 @@ function doblocks($data, $user)
else else
$row = 'odd'; $row = 'odd';
if ($bmon == $nowmon && $byyyy == $nowyyyy)
$dots = '&hellip;';
else
$dots = '';
$elap = $bcd - $cd;
$phr = ($bdiffacc / $elap) * pow(2, 32);
$phrdsp = siprefmt($phr);
$name = gmdate('Y M', $bcd); $name = gmdate('Y M', $bcd);
$exc = number_format($bdiffratio, 2); $exc = number_format($bdiffratio, 2);
if ($bdiffratio > $bcount)
$bcol = 'darkred';
else
$bcol = 'darkgreen';
$md = number_format(100 * $bdiffratio / $bcount, 2); $md = number_format(100 * $bdiffratio / $bcount, 2);
$mr = number_format(100 * $btxn / $bcount, 2); $mr = number_format(100 * $btxn / $bcount, 2);
$ml = number_format(100 * $bcount / $bdiffratio, 2); $ml = number_format(100 * $bcount / $bdiffratio, 2);
$o = number_format((100 - $poolfee) * ($bcount / $bdiffratio) * ($btxn / $bcount), 2); $oa = (100 - $poolfee) * ($bcount / $bdiffratio) * ($btxn / $bcount);
$odsp = number_format($oa, 2);
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= "<td class=dl>$name</td>"; $pg .= "<td class=dl>$name$dots</td>";
$pg .= "<td class=dr>$bcount</td>"; $pg .= "<td class=dr>${phrdsp}Hs</td>";
$pg .= "<td class=dr><b><font color=$bcol>$bcount</font></b></td>";
$pg .= "<td class=dr>$exc</td>"; $pg .= "<td class=dr>$exc</td>";
$pg .= "<td class=dr>$md%</td>"; $pg .= "<td class=dr>$md%</td>";
$pg .= "<td class=dr>$mr%</td>"; $pg .= "<td class=dr>$mr%</td>";
$pg .= "<td class=dr>$ml%</td>"; $pg .= "<td class=dr>$ml%</td>";
$pg .= "<td class=dr>$o%</td>"; $pg .= "<td class=dr>$odsp%</td>";
$pg .= "</tr>\n"; $pg .= "</tr>\n";
$rout++; $rout++;
} }
if ($rout > 7) if ($rout > $limit)
break; break;
$bcd = $cd; $bcd = $cd;
$bmon = $mon; $bmon = $mon;
$byyyy = $yyyy; $byyyy = $yyyy;
$bcount = 0; $bcount = $bdiffacc = $bdiffratio = $btxn = 0;
$bdiffratio = 0;
$btxn = 0;
} }
$bdiffratio += floatval($ans['diffratio:'.$i]); $bdiffratio += floatval($ans['diffratio:'.$i]);
$bdiffacc += floatval($ans['diffacc:'.$i]);
if ($conf != 'O' and $conf != 'R') if ($conf != 'O' and $conf != 'R')
{ {
@ -235,7 +241,32 @@ function doblocks($data, $user)
} }
} }
$pg .= '</tbody></table>'; $pg .= '</tbody></table>';
}
return $pg;
}
#
function doblocks($data, $user)
{
$blink = '<a href=https://www.blocktrail.com/BTC/block/';
$poolfee = 0.9; # pool fee as a % out of 100
$pg = '';
if ($user === null)
$ans = getBlocks('Anon');
else
$ans = getBlocks($user);
if (nuem(getparam('csv', true)))
$wantcsv = false;
else
$wantcsv = true;
if ($wantcsv === false)
{
$pg .= statstable($poolfee, $ans, $data);
$pg .= monthtable($poolfee, $ans, 7);
if ($ans['STATUS'] == 'ok') if ($ans['STATUS'] == 'ok')
{ {

Loading…
Cancel
Save