Example #1
0
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;
}
Example #2
0
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;
}
Example #3
0
function difffmt($amt)
{
    return siprefmt($amt, 3);
}
Example #4
0
function pgtop($info, $dotop, $user, $douser)
{
    global $site_title, $loginfailed;
    $phr = '?THs';
    $plb = '?';
    $nlb = '?';
    $pac = '0';
    $per = '0';
    $perset = false;
    $uhr = '?GHs';
    $u1hr = '';
    if ($info !== false) {
        $now = time();
        if (isset($info['p_hashrate5m'])) {
            $phr = $info['p_hashrate5m'];
        }
        //	if (isset($info['p_elapsed'])
        //	and isset($info['p_hashrate1hr'])
        //	and $info['p_elapsed'] > 3600)
        //		$phr = $info['p_hashrate1hr'];
        if ($phr == '?') {
            $phr = '?THs';
        } else {
            $phr = dsprate($phr);
        }
        if (isset($info['lastblock'])) {
            $plb = $info['lastblock'];
            if ($plb != '?') {
                $sec = $now - $plb;
                if ($sec < 60) {
                    $plb = $sec . 's';
                } else {
                    if ($sec < 3600) {
                        $min = round($sec / 60);
                        $plb = $min . 'm';
                    } else {
                        $min = round($sec / 60);
                        $hr = round($min / 60);
                        $min -= $hr * 60;
                        $plb = $hr . 'h';
                        if ($min > 0) {
                            $plb .= '&nbsp;' . $min . 'm';
                        }
                    }
                }
            }
        }
        if (isset($info['lastblockheight'])) {
            $plb .= ' (' . $info['lastblockheight'] . ')';
        }
        if (isset($info['lastbc'])) {
            $nlb = $info['lastbc'];
            if ($nlb != '?') {
                $sec = $now - $nlb;
                $min = round($sec / 60);
                $nlb = $min . 'm';
                $s = $sec - $min * 60;
                if ($s > 0) {
                    $nlb .= "&nbsp;{$s}s";
                }
            }
        }
        if (isset($info['lastheight'])) {
            $nlb .= ' (' . $info['lastheight'] . ')';
        }
        if (isset($info['blockacc'])) {
            $acc = $info['blockacc'];
            $pac = number_format($acc, 0);
            if (isset($info['currndiff'])) {
                $cur = $info['currndiff'];
                if ($cur != '?' && $cur > 0.0) {
                    $pac .= ' (' . number_format(100.0 * $acc / $cur, 2) . '%)';
                }
            }
        }
        if (isset($info['blockshareinv'])) {
            $shinv = $info['blockshareinv'];
            $per = siprefmt($shinv, 1);
            $perset = true;
            if (isset($info['blockshareacc'])) {
                $shacc = $info['blockshareacc'];
                if ($shacc + $shinv > 0) {
                    $amt = 100.0 * $shinv / ($shacc + $shinv);
                    if (round($amt, 2) > 9.99) {
                        $per .= ' (' . number_format($amt, 1) . '%)';
                    } else {
                        $per .= ' (' . number_format($amt, 2) . '%)';
                    }
                }
            }
        }
        if (isset($info['blockerr'])) {
            if ($perset == false) {
                $per = '';
            } else {
                $per .= ' &#183; ';
            }
            $inv = $info['blockerr'];
            $per .= siprefmt($inv, 1);
            if (isset($info['blockacc'])) {
                $acc = $info['blockacc'];
                if ($acc + $inv > 0) {
                    $amt = 100.0 * $inv / ($acc + $inv);
                    if (round($amt, 2) > 9.99) {
                        $per .= ' (' . number_format($amt, 1) . '%)';
                    } else {
                        $per .= ' (' . number_format($amt, 2) . '%)';
                    }
                }
            }
        }
        if (isset($info['u_hashrate5m'])) {
            $uhr = $info['u_hashrate5m'];
            if ($uhr == '?') {
                $uhr = '?GHs';
            } else {
                $uhr = dsprate($uhr);
            }
        }
        if (isset($info['u_hashrate1hr']) and isset($info['u_elapsed']) and $info['u_elapsed'] > 3600) {
            $u1hr = $info['u_hashrate1hr'];
            if ($u1hr == '?') {
                $u1hr = '';
            } else {
                $u1hr = '/' . dsprate($u1hr);
                // Remove the first XHs if they are the same
                if (substr($u1hr, -3) == substr($uhr, -3)) {
                    $uhr = substr($uhr, 0, -3);
                }
            }
        }
    }
    $top = "<noscript><div class=jst id=jst>&nbsp;Javascript isn't enabled.";
    $top .= " You need to enable javascript to use";
    $top .= " the {$site_title} web site.</div></noscript>";
    if ($loginfailed === true) {
        $top .= '<div class=accwarn>Login Failed</div>';
    }
    if (isset($info['u_nopayaddr'])) {
        $top .= '<div class=accwarn>Please set a payout address on your account!</div>';
    }
    if (isset($info['u_noemail'])) {
        $top .= '<div class=accwarn>Please set an email address on your account!</div>';
    }
    $top .= '<div class=topd>';
    if ($dotop === true) {
        $lh = '';
        $ls = '';
        $lw = '';
        if (isset($info['now']) && isset($info['lastsh']) && isset($info['lasthb']) && isset($info['lastwi'])) {
            $lsn = $info['now'] - $info['lastsh'];
            $lhn = $info['now'] - $info['lasthb'];
            $lwn = $info['now'] - $info['lastwi'];
            if ($lsn < 8) {
                $lsc = 'green.png';
            } else {
                if ($lsn < 10) {
                    $lsc = 'orange.png';
                } else {
                    $lsc = 'red.png';
                }
            }
            if ($lhn < 5) {
                $lhc = 'green.png';
            } else {
                if ($lhn < 10) {
                    $lhc = 'orange.png';
                } else {
                    $lhc = 'red.png';
                }
            }
            if ($lwn < 36) {
                $lwc = 'green.png';
            } else {
                if ($lwn < 46) {
                    $lwc = 'orange.png';
                } else {
                    $lwc = 'red.png';
                }
            }
            $img1 = '<img border=0 src=/';
            $img2 = '>';
            $ls = $img1 . $lsc . $img2;
            $lh = $img1 . $lhc . $img2;
            $lw = $img1 . $lwc . $img2;
        }
        if (!isset($info['users'])) {
            $info['users'] = '?';
        }
        if (!isset($info['workers'])) {
            $info['workers'] = '?';
        }
        $top .= '<table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td>';
        $top .= '<table cellpadding=1 cellspacing=0 border=0>';
        $top .= "<tr><td class=topdes>{$lh}</td></tr>";
        $top .= "<tr><td class=topdes>{$ls}</td></tr>";
        $top .= "<tr id=mini0><td class=topdes>{$lw}</td></tr></table>";
        $top .= '</td><td>';
        $top .= '<table cellpadding=1 cellspacing=0 border=0 width=100%>';
        $top .= '<tr><td class=topdes>CKPool:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$phr}</td></tr>";
        $top .= '<tr><td class=topdes>Shares:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$pac}</td></tr>";
        $top .= '<tr id=mini1><td class=topdes>Invalids:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$per}</td></tr></table>";
        $top .= '</td><td>';
        $top .= '<table cellpadding=1 cellspacing=0 border=0 width=100%>';
        $top .= '<tr><td class=topdes>Last&nbsp;</td>';
        $top .= '<td class=topdesl>Block</td></tr>';
        $top .= '<tr><td class=topdes>Pool:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$plb}</td></tr>";
        $top .= '<tr id=mini2><td class=topdes>Network:&nbsp;</td>';
        $top .= "<td class=topdat>&nbsp;{$nlb}</td></tr></table>";
        $top .= '</td><td id=mini3>';
        $top .= '<table cellpadding=1 cellspacing=0 border=0 width=100%>';
        $top .= '<tr><td class=topdes>Users:&nbsp;</td>';
        $top .= '<td class=topdat>&nbsp;' . $info['users'] . '</td></tr>';
        $top .= '<tr><td class=topdes>Workers:&nbsp;</td>';
        $top .= '<td class=topdat>&nbsp;' . $info['workers'] . '</td></tr></table>';
        $top .= '</td><td>';
        if ($douser === true) {
            $top .= '<span class=login>';
            list($who, $whoid) = validate();
            if ($who == false) {
                $top .= '<table cellpadding=0 cellspacing=0 border=0><tr><td>';
                $top .= '<a href="https://' . $_SERVER['SERVER_NAME'];
                $top .= '/index.php?Register=1">Login<br>Register</a>';
                $top .= '</td></tr></table>';
            } else {
                $extra = '';
                if (strlen($who) > 12) {
                    $who = substr($who, 0, 12);
                    $extra = '&#133;';
                }
                $top .= "<span class=topwho>" . htmlspecialchars($who) . "{$extra}&nbsp;</span>";
                $top .= makeForm('');
                $top .= "<input type=submit name=Logout value=Logout></form>";
                $top .= "<br><span class=topdes>Hash&nbsp;Rate:</span>";
                $top .= "<span class=topdat>{$uhr}{$u1hr}</span><br>";
            }
            $top .= '</span>';
        }
        $top .= '</td></tr></table>';
    } else {
        $top .= '&nbsp;';
    }
    $top .= '</div>';
    return $top;
}