From d793da51c7b5b7dd30c3348e694b1127d27773a4 Mon Sep 17 00:00:00 2001 From: kanoi Date: Tue, 18 Oct 2016 11:20:33 +1100 Subject: [PATCH] php - some monthly block stats --- pool/page_blocks.php | 91 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/pool/page_blocks.php b/pool/page_blocks.php index 1affd737..bc71d2b2 100644 --- a/pool/page_blocks.php +++ b/pool/page_blocks.php @@ -72,6 +72,7 @@ function pctcolour($pct) function doblocks($data, $user) { $blink = ' 0) + { + $pg .= '

Monthly Statistics

'; + $pg .= "\n"; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= "\n"; + + $pg .= ''; + $count = $ans['rows']; + $rout = $bcount = $bcd = $bmon = $byyyy = $bdiffratio = $btxn = 0; + $skipped = false; + for ($i = 0; $i < $count; $i++) + { + $conf = $ans['confirmed:'.$i]; + // Skip leading orphans + if (!$skipped && ($conf == 'O' || $conf == 'R')) + continue; + + $skipped = true; + + // If anything is missing, skip this table + $diffratio = $ans['diffratio:'.$i]; + if ($diffratio == '?') + break; + + $cd = $ans['firstcreatedate:'.$i]; + $mon = intval(gmdate('n', $cd)); + $yyyy = intval(gmdate('Y', $cd)); + // all orphans after a block must be included with that block + if (($conf != 'O' && $conf != 'R') + && ($mon != $bmon || $yyyy != $byyyy)) + { + if ($bcount != 0) + { + if (($rout % 2) == 0) + $row = 'even'; + else + $row = 'odd'; + + $name = gmdate('Y M', $bcd); + $exc = number_format($bdiffratio, 2); + $md = number_format(100 * $bdiffratio / $bcount, 2); + $mr = number_format(100 * $btxn / $bcount, 2); + $ml = number_format(100 * $bcount / $bdiffratio, 2); + $o = number_format((100 - $poolfee) * ($bcount / $bdiffratio) * ($btxn / $bcount), 2); + + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= ""; + $pg .= "\n"; + + $rout++; + } + if ($rout > 7) + break; + + $bcd = $cd; + $bmon = $mon; + $byyyy = $yyyy; + $bcount = 0; + $bdiffratio = 0; + $btxn = 0; + } + $bdiffratio += floatval($ans['diffratio:'.$i]); + + if ($conf != 'O' and $conf != 'R') + { + $height = $ans['height:'.$i]; + $reward = floatval($ans['reward:'.$i]); + $re = 5000000000.0 * pow(0.5, floor($height / 210000.0)); + $btxn += $reward / $re; + $bcount++; + } + } + $pg .= '
UTC MonthBlocksExpectedMean Diff%MeanTx%Luck%PPS%
$name$bcount$exc$md%$mr%$ml%$o%
'; + } + if ($ans['STATUS'] == 'ok') { $count = $ans['rows'];