function dopayout($data, $user) { $N = 5; $t = "<span class=nn>{$N}</span>"; $ot = "<span class=nn>1/{$N}</span>"; $n = "<span class=nn>{$N}Nd</span>"; $n1 = '<span class=nn>N</span>'; $n1d = '<span class=nn>Nd</span>'; $bc = '+101 Confirms'; $bm = 'Matured'; $nd = 0; if (isset($data['info']['currndiff'])) { $nd = $data['info']['currndiff']; } $nv = number_format($nd, 1); $nvx = '<b>' . number_format($N * $nd, 1) . '</b>'; $pd = $data['info']['p_hashrate24hr']; $hr = 'is <b>?</b>'; $hrt = '<b>?</b>'; if ($pd != '?' && $pd != '' && $pd > 0) { $hr = 'for the last day is roughly <b>' . siprefmt($pd, 2) . 'Hs</b>'; if ($nd > 0) { $hrt = '<b>' . howmanyhrs($nd * $N / ($pd / pow(2, 32)), true, true) . '</b>'; } } $pg = "<h1>Payouts</h1>\n<table width=75% cellpadding=0 cellspacing=0 border=0><tr><td>\n\n<span class=hdr>What payout method does the pool use?</span><br><br>\nWe use <b>PPL{$n1}S</b> (<b>P</b>ay <b>P</b>er <b>L</b>ast {$n1} <b>S</b>hares)<br><br>\n<b>PPL{$n1}S</b> means that when a block is found, the block reward is shared among the last {$n1} shares that miners sent to the pool, up to when the block was found.<br>\nThe {$n1} value the pool uses is {$t} times the network difficulty when the block is found - '{$n}'.<br><br>\n\n<span class=hdr>How much of each block does the pool reward?</span><br><br>\nTransaction fees are included in the miner reward.<br>\nPool fee is 0.9% of the total.<br><br>\n\n<span class=hdr>PPL{$n1}S acts like the reward 'ramps up' when you first start mining.<br>What actually happens?</span><br><br>\nThe {$n} means it takes that long to reward your shares.<br>\nThe ramp isn't missing rewards, it's delaying them to reduce variance.<br>\nEach share is rewarded in all the blocks found in the {$n} after the share.<br>\nThat's simply how it reduces variance. Each share's reward is averaged out over the {$n} after it.<br>\nThe pool hash rate {$hr} which means the {$n} 'ramp' is roughly {$hrt}.<br><br>\n\nContinue reading below for more detail about how it works:<br><br>\n\n<span class=hdr>How do the <b>PPL{$n1}S</b> payments work?</span><br><br>\nThe {$n} means the pool rewards {$t} times the expected number of shares, each time a block is found.<br>\nSo each share will be paid approximately {$ot} of it's expected value, in each block it gets a reward,<br>\nbut each share is also expected, on average, to be rewarded {$t} times in blocks found after the share is submitted to the pool.<br>\ni.e. if pool luck was always 100% then each share is expected to be rewarded {$t} times.<br><br>\nIf pool luck is better than 100%, then the average share reward will be better than {$t} times.<br>\nIf pool luck is lower than 100%, then the average share reward will be less than {$t} times.<br><br>\n\n<span class=hdr>What's a shift?</span></br><br>\nWhen your miner sends shares to the pool, the shares are not stored individually, but rather summarised into shifts.<br>\nShifts are ~50min or less in length.<br>\nAproximately every 30s, the pool generates new work and sends that to all the miners.<br>\nThe pool also sends new work every time a block is found on the Bitcoin network.<br>\nA shift summarises all the shares submitted to the pool for 100 work changes.<br>\nHowever, when we find pool blocks, the current shift ends at the work in which the block was found<br>\nand a new shift starts.<br>\nA ckpool restart will also end the current shift and start a new shift.<br>\nA network difficulty change will also end the current shift and start a new shift.<br><br>\n\n<span class=hdr>So, what's the {$n} value?</span><br><br>\nThe current Bitcoin network value for {$n1d} is {$nv} and thus {$n} is {$nvx}<br>\nBitcoin adjusts the {$n1d} value every 2016 blocks, which is about every 2 weeks.<br><br>\nWhen a block is found, the reward process counts back shifts until the total share difficulty included is {$n}.<br>\nSince shares are summarised into shifts, it will include the full shift at the end of the range counting backwards,<br>\nso it usually will be a bit more than {$n}.<br><br>\n\n<span class=hdr>When are payments sent out?</span><br><br>\nThe block 'Status' must first reach '{$bc}' on the Blocks page, and then is flagged as '{$bm}', before the reward is distributed.<br>\nThe block reward is sent out manually soon after that.<br><br>\n\n</td></tr></table>"; return $pg; }
function dompayouts($data, $user) { $pg = '<h1>Mining Rewards</h1>'; $ans = getMPayouts($user); $pg .= "The rewards you've earned for each block the pool has found.<br>"; $pg .= 'See the '; $pg .= makeLink('payments'); $pg .= "Payments</a> page for the payments you've been sent.<br><br>"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<tr class=title>"; $pg .= "<td class=dr>Block</td>"; $pg .= "<td class=dr>Block UTC</td>"; $pg .= "<td class=dr>Miner Reward</td>"; $pg .= "<td class=dr>N Diff</td>"; $pg .= "<td class=dr>N Range</td>"; $pg .= "<td class=dr>Pool N Avg</td>"; $pg .= "<td class=dr>Your %</td>"; $pg .= "<td class=dr>Your N Diff</td>"; $pg .= "<td class=dr>Your N Avg</td>"; $pg .= "<td class=dr>Your BTC</td>"; $pg .= "</tr>\n"; if ($ans['STATUS'] == 'ok') { $totamt = 0; $count = $ans['rows']; for ($i = 0; $i < $count; $i++) { if ($i % 2 == 0) { $row = 'even'; } else { $row = 'odd'; } $pg .= "<tr class={$row}>"; $pg .= '<td class=dr>' . $ans['height:' . $i] . '</td>'; $pg .= '<td class=dr>' . gmdate('j/M H:i', $ans['blockcreatedate:' . $i]) . '</td>'; $pg .= '<td class=dr>' . btcfmt($ans['minerreward:' . $i]) . '</td>'; $diffused = $ans['diffused:' . $i]; $pg .= '<td class=dr>' . difffmt($diffused) . '</td>'; $elapsed = $ans['elapsed:' . $i]; $pg .= '<td class=dr>' . howmanyhrs($elapsed) . '</td>'; $phr = $diffused * pow(2, 32) / $elapsed; $pg .= '<td class=dr>' . siprefmt($phr) . 'Hs</td>'; $diffacc = $ans['diffacc:' . $i]; $ypct = $diffacc * 100 / $diffused; $pg .= '<td class=dr>' . number_format($ypct, 2) . '%</td>'; $pg .= '<td class=dr>' . difffmt($diffacc) . '</td>'; $hr = $diffacc * pow(2, 32) / $elapsed; $pg .= '<td class=dr>' . dsprate($hr) . '</td>'; $amount = $ans['amount:' . $i]; $totamt += $amount; $pg .= '<td class=dr>' . btcfmt($amount) . '</td>'; $pg .= "</tr>\n"; } if ($count > 1) { if ($i % 2 == 0) { $row = 'even'; } else { $row = 'odd'; } $pg .= "<tr class={$row}>"; $pg .= '<td class=dr>Total:</td>'; $pg .= '<td class=dl colspan=8></td>'; $pg .= '<td class=dr>' . btcfmt($totamt) . '</td>'; $pg .= "</tr>\n"; } } $pg .= "</table>\n"; return $pg; }
function doshifts($data, $user) { $ans = getShifts($user); $pg = "Click <a href='#payoutmark'>here</a> to jump to the start of the last payout<br><br>"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<tr class=title>"; $pg .= "<td class=dl>Shift</td>"; $pg .= "<td class=dl>Start UTC</td>"; $pg .= "<td class=dr>Length</td>"; $pg .= "<td class=dr>Your Diff</td>"; $pg .= "<td class=dr>Inv Diff</td>"; $pg .= "<td class=dr>Avg Hs</td>"; $pg .= "<td class=dr>Shares</td>"; $pg .= "<td class=dr>Avg Share</td>"; $pg .= "<td class=dr>Rewards</td>"; $pg .= "<td class=dr>Rewarded<span class=st1>*</span></td>"; $pg .= "<td class=dr>PPS%</td>"; $pg .= "</tr>\n"; if ($ans['STATUS'] != 'ok' || !isset($ans['prefix_all'])) { $pg = '<h1>Shifts</h1>' . $pg; } else { $pre = $ans['prefix_all']; $count = $ans['rows']; $pg = '<h1>Last ' . ($count + 1) . ' Shifts</h1>' . $pg; for ($i = 0; $i < $count; $i++) { $u = ''; $mark = ''; if (isset($ans['lastpayoutstart:' . $i]) && $ans['lastpayoutstart:' . $i] != '') { $u = 'u'; $mark = '<a name=payoutmark></a>'; } if ($i % 2 == 0) { $row = "even{$u}"; } else { $row = "odd{$u}"; } $pg .= "<tr class={$row}>"; $shifname = $ans['shift:' . $i]; $shif = preg_replace(array('/^.* to /', '/^.*fin: /'), '', $shifname); $ablock = false; if (preg_match('/to.*Block.* fin/', $shifname) == 1) { $ablock = true; } else { $shifex = $ans['endmarkextra:' . $i]; if (preg_match('/Block .* fin/', $shifex) == 1) { $ablock = true; } } if ($ablock === true) { $btc = ' <img src=/BTCSym.png border=0>'; } else { $btc = ''; } $pg .= "<td class=dl>{$shif}{$btc}{$mark}</td>"; $start = $ans['start:' . $i]; $pg .= '<td class=dl>' . utcd($start, true) . '</td>'; $nd = $ans['end:' . $i]; $elapsed = $nd - $start; $pg .= '<td class=dr>' . howmanyhrs($elapsed) . '</td>'; $diffacc = $ans[$pre . 'diffacc:' . $i]; $pg .= '<td class=dr>' . difffmt($diffacc) . '</td>'; $diffinv = $ans[$pre . 'diffinv:' . $i]; $pg .= '<td class=dr>' . difffmt($diffinv) . '</td>'; $hr = $diffacc * pow(2, 32) / $elapsed; $pg .= '<td class=dr>' . dsprate($hr) . '</td>'; $shareacc = $ans[$pre . 'shareacc:' . $i]; $pg .= '<td class=dr>' . difffmt($shareacc) . '</td>'; if ($shareacc > 0) { $avgsh = $diffacc / $shareacc; } else { $avgsh = 0; } $pg .= '<td class=dr>' . number_format($avgsh, 2) . '</td>'; $pg .= '<td class=dr>' . $ans['rewards:' . $i] . '</td>'; $ppsr = (double) $ans['ppsrewarded:' . $i]; if ($ppsr > 0) { $ppsd = sprintf('%.5f', $ppsr); } else { $ppsd = '0'; } $pg .= "<td class=dr>{$ppsd}</td>"; $ppsv = (double) $ans['ppsvalue:' . $i]; if ($ppsv > 0) { $pgot = number_format(100.0 * $ppsr / $ppsv, 2) . '%'; } else { $pgot = '?'; } $pg .= "<td class=dr>{$pgot}</td>"; $pg .= "</tr>\n"; } } $pg .= "</table>\n"; $pg .= "<span class=st1>*</span> The Rewarded value unit is satoshis per 1diff share<br>"; return $pg; }
function workuser($data, $user, &$offset, &$totshare, &$totdiff, &$totshrate, &$totinvalid, &$totrate, &$blockacc, &$blockreward, $old = false, $srt = false, $one = false, &$title, &$instances) { $ans = getWorkers($user); $pg = ''; if ($ans['STATUS'] == 'ok') { if (isset($ans['blockacc'])) { $blockacc = $ans['blockacc']; } if (isset($ans['blockreward'])) { $blockreward = $ans['blockreward']; } if ($one === true && isset($ans['oldworkers'])) { $days = intval($ans['oldworkers']); if ($days != 0) { $title = ' (active during the last ' . $days . ' day' . ($days == 1 ? '' : 's') . ')'; } } $all = array(); $count = $ans['rows']; $now = $ans['STAMP']; for ($i = 0; $i < $count; $i++) { $lst = $now - $ans['w_lastshare:' . $i]; if ($old !== false && $lst > $old) { 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_lastshareacc' => $ans['w_lastshareacc:' . $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_diffsta' => $ans['w_diffsta:' . $i], 'w_diffdup' => $ans['w_diffdup:' . $i], 'w_diffhi' => $ans['w_diffhi:' . $i], 'w_diffrej' => $ans['w_diffrej:' . $i], 'w_sharesta' => $ans['w_sharesta:' . $i], 'w_sharedup' => $ans['w_sharedup:' . $i], 'w_sharehi' => $ans['w_sharehi:' . $i], 'w_sharerej' => $ans['w_sharerej:' . $i], 'w_lastdiff' => $ans['w_lastdiff:' . $i], 'w_active_diffacc' => $ans['w_active_diffacc:' . $i], 'w_active_start' => $ans['w_active_start:' . $i], 'w_uhr' => $uhr); $instances += $ans['w_instances:' . $i]; } if ($srt) { usort($all, 'workhashorder'); } foreach ($all as $arow) { $lst = $now - $arow['w_lastshare']; if ($old !== false && $lst > $old) { continue; } $lstacc = $now - $arow['w_lastshareacc']; if ($offset % 2 == 0) { $row = 'even'; } else { $row = 'odd'; } $pg .= "<tr class={$row}>"; $pg .= '<td class=dl>' . htmlspecialchars($arow['workername']) . '</td>'; if ($arow['w_lastdiff'] > 0) { $ld = difffmt($arow['w_lastdiff']); } else { $ld = ' '; } $pg .= "<td class=dr>{$ld}</td>"; $pg .= "<td class=dr data-srt={$lstacc}>" . howlongago($lstacc) . '</td>'; $shareacc = number_format($arow['w_shareacc'], 0); $totshare += $arow['w_shareacc']; $dacc = $arow['w_diffacc']; $diffacc = number_format($dacc, 0); $ds = round($dacc); $totdiff += $dacc; $pg .= "<td class=dr>{$shareacc}</td>"; $pg .= "<td class=dr data-srt={$ds}>{$diffacc}</td>"; $acthr = '0'; $acthrv = 0; $actstt = $arow['w_active_start']; if ($actstt <= 0 || $now - $actstt < 0) { $actsin = ' '; } else { $actsin = howmanyhrs($now - $actstt); $elapsed = $now - $actstt; if ($elapsed > 0) { $acthrv = $arow['w_active_diffacc'] * pow(2, 32) / $elapsed; $acthr = dsprate($acthrv); $totshrate += $acthrv; } } $pg .= "<td class=dr data-srt={$acthrv}>{$acthr}</td>"; $pg .= "<td class=dr>{$actsin}</td>"; $dinv = $arow['w_diffinv']; $dtot = $dacc + $dinv; if ($dtot > 0) { $rejf = $dinv / $dtot; $rej = number_format(100.0 * $rejf, 3); } else { $rejf = 0; $rej = '0'; } $totinvalid += $dinv; $pg .= "<td class=dr data-srt={$rejf}>{$rej}%</td>"; foreach (array('sta', 'dup', 'hi', 'rej') as $fld) { $shr = number_format($arow['w_share' . $fld]); $dif = $arow['w_diff' . $fld]; $ddif = number_format($dif); $sdif = number_format($dif, 0, '', ''); $pg .= "<td class=hid data-srt={$sdif} data-hid=dr>{$ddif}/{$shr}</td>"; } if ($blockacc <= 0) { $blkpct = ' '; } else { $blkpct = number_format(100.0 * $dacc / $blockacc, 3) . '%'; } $pg .= "<td class=dr>{$blkpct}</td>"; $uhr = $arow['w_uhr']; if ($uhr == '?') { $uhr = '?GHs'; $su = 0; } else { $su = round($uhr); $totrate += $uhr; $uhr = dsprate($uhr); } $pg .= "<td class=dr data-srt={$su}>{$uhr}</td>"; $pg .= "</tr>\n"; $offset++; } } return $pg; }
function fmtdata($code, $val) { switch ($code) { case ',': $ret = number_format($val); break; case '.': $ret = number_format($val, 1); break; case '@': $ret = howmanyhrs($val, true); break; default: $ret = $val; } return $ret; }