Ejemplo n.º 1
0
                $aheadtext = prettySatoshis($tb + 2500000000 * $bc) . " " . ($tb + 2500000000 * ($bc + 1) == 1 ? "is" : "are") . " ahead in queue";
            }
        }
        if ($bc == 0) {
            $delay = "in our next block";
        } else {
            $delay = "after a {$bc} block delay";
        }
        print $aheadtext . ", putting this user's payout {$delay}.<BR><SMALL style=\"font-size: 70%\"><I>Note: This is constantly changing. See <A HREF=\"http://eligius.st/~wizkid057/newstats/payoutqueue.php#{$givenuser}\">the payout queue</A>.</I></SMALL>";
    }
    print "</span>";
    print "<BR><BR><HR>";
}
if ($u16avghash > 0) {
    if (!isset($netdiff)) {
        $sql = "select id,(pow(10,((29-hex_to_int(substr(encode(solution,'hex'),145,2)))::double precision*2.4082399653118495617099111577959::double precision)+log(  (65535::double precision /  hex_to_int(substr(encode(solution,'hex'),147,6)))::double precision   )::double precision))::double precision as network_difficulty from shares where server={$serverid} and our_result=true order by id desc limit 1;";
        $result = pg_exec($link, $sql);
        $row = pg_fetch_array($result, 0);
        $netdiff = $row["network_difficulty"];
    }
    $satoshiperday = round($u16avghash * 86400 / 4294967296 * (2500000000 / $netdiff), 0);
    $netdiff = round($netdiff, 2);
    print "<BR><B>Estimated Earnings</B><BR>";
    print "<span style=\"font-size: 0.8em\">";
    print "Your approximate maximum potential earnings at the current network difficulty of " . number_format($netdiff, 2) . " and maintaining your 3-hour average hash rate of " . prettyHashrate($u16avghash) . " is " . prettySatoshis($satoshiperday) . " per day.\n";
    print "</span>";
    print "<BR><BR><HR>";
}
print "</div>";
print "<BR><SMALL>(The data on this page is cached and updated periodically, generally about 30 seconds for the short-timeframe hashrate numbers, balances, and rejected shares data; and about 675 seconds for the graphs, longer-timeframe hashrate numbers, and other datas.</SMALL><BR>";
print_stats_bottom();
Ejemplo n.º 2
0
     $output["rows"][$ri]["duration"] = $row["duration"];
     $output["rows"][$ri]["age"] = $row["age"];
     $output["rows"][$ri]["roundstart"] = $row["start_unix"];
     $output["rows"][$ri]["roundend"] = $row["time_unix"];
     $output["rows"][$ri]["hashrate"] = sprintf("%u", $hashrate);
     $output["rows"][$ri]["percent_of_network"] = 100 * ($hashrate / ($row["network_difficulty"] * 7158278.82667));
     $output["rows"][$ri]["accepted_shares"] = sprintf("%u", $row["acceptedshares"]);
     $output["rows"][$ri]["network_difficulty"] = sprintf("%.4f", $row["network_difficulty"]);
     $output["rows"][$ri]["block_finder"] = $fulladdress;
     $output["rows"][$ri]["block_finder_user_id"] = $row["user_id"];
     if ($showpretty) {
         $output["rows"][$ri]["luck_pretty"] = number_format(round($luck, 1), 1) . "%";
         $output["rows"][$ri]["roundstart_pretty"] = substr($row["roundstart"], 0, 19);
         $output["rows"][$ri]["roundend_pretty"] = substr($row["time"], 0, 19);
         $output["rows"][$ri]["percent_of_network_pretty"] = number_format(round($output["rows"][$ri]["percent_of_network"], 1), 1) . "%";
         $output["rows"][$ri]["hashrate_pretty"] = prettyHashrate($hashrate);
         $output["rows"][$ri]["age_pretty"] = prettyDuration($row["age"], false, 1);
         $output["rows"][$ri]["duration_pretty"] = "{$hours}:{$minutes}:{$seconds}";
         $output["rows"][$ri]["network_difficulty_pretty"] = formatSI($row["network_difficulty"], 2);
         if ($row["confirmations"] >= 120) {
             $confs = "Confirmed";
         } else {
             if ($row["confirmations"] == 0) {
                 $confs = "Stale";
             } else {
                 $confs = $row["confirmations"] . " of 120";
             }
         }
         $output["rows"][$ri]["confirmations_pretty"] = $confs;
     }
 }
Ejemplo n.º 3
0
                $sql = "select (sum(accepted_shares)*pow(2,32))/1350 as avghash,sum(accepted_shares) as share_total from {$psqlschema}.stats_shareagg where server={$serverid} and time > to_timestamp({$sql2res})-'1350 seconds'::interval";
                $result = pg_exec($link, $sql);
                $row = pg_fetch_array($result, 0);
                $hashrate256 = $row["avghash"];
                # note that cppsrb is not ok
                apc_store('cppsrb_ok', -1, 90);
            }
        }
        # get latest block height
        $sql = "select date_part('epoch',NOW() - time) as roundduration,height,confirmations from {$psqlschema}.stats_blocks where server={$serverid} and confirmations > 0 and height > 0 order by height desc limit 1;";
        $result = pg_exec($link, $sql);
        $row = pg_fetch_array($result, 0);
        $blockheight = $row["height"];
        $roundduration = $row["roundduration"];
        $latestconfirms = $row["confirmations"];
        $sharesperunit = $hashrate256 / 4294967296 / 20;
        $phash = prettyHashrate($hashrate256);
        $datanew = 1;
        $sql = "select pg_advisory_unlock(1000002) as l";
        $result = pg_exec($link, $sql);
        $row = pg_fetch_array($result, 0);
    }
}
if (!($roundshares > 0)) {
    $roundshares = 0;
}
$tline = "{\"sharesperunit\":{$sharesperunit},\"roundsharecount\":{$roundshares},\"lastblockheight\":{$blockheight},\"lastconfirms\":{$latestconfirms},\"roundduration\":{$roundduration},\"hashratepretty\":\"{$phash}\",\"network_difficulty\":{$netdiff}}";
if ($datanew) {
    # cache this for 30 seconds, should be good enough
    set_stats_cache($link, 5, "livedata.json", $tline, 30);
}
Ejemplo n.º 4
0
 $row = pg_fetch_array($result, 0);
 $stime = $row["stime"];
 $sql = "select (sum(accepted_shares)*pow(2,32))/10800 as avghash from {$psqlschema}.stats_shareagg where server={$serverid} and time > '{$stime}'::timestamp without time zone";
 $result = pg_exec($link, $sql);
 $row = pg_fetch_array($result, 0);
 $poolhashrate3hr = $row["avghash"];
 $sql = "select (sum(accepted_shares)*pow(2,32))/10800 as avghash, sum(accepted_shares) as sharecount, keyhash, min(users.id) as user_id from {$psqlschema}.stats_shareagg left join users on user_id=users.id where server={$serverid} and time > '{$stime}'::timestamp without time zone and accepted_shares > 0 group by keyhash order by avghash desc {$minilimit};";
 $result = pg_exec($link, $sql);
 $numrows = pg_numrows($result);
 $pdata = "<TABLE BORDER=1 class=\"contributors\">";
 $pdata .= "<TR class=\"contribhead\"><TD>Rank</TD><TD>Address</TD><TD>3-hr Avg Hashrate</TD><TD>3-hr Shares</TD><TD>Percentage of Pool</TD></TR>";
 $oe = 0;
 $rank = 1;
 for ($ri = 0; $ri < $numrows; $ri++) {
     $row = pg_fetch_array($result, $ri);
     $phash = prettyHashrate($row["avghash"]);
     $tpercent = $row["avghash"] / $poolhashrate3hr * 100;
     $tpercent = round($tpercent, 4);
     $user_id = $row["user_id"];
     if (isset($row['keyhash'])) {
         $address = \Bitcoin::hash160ToAddress(bits2hex($row['keyhash']));
         $nickname = get_nickname($link2, get_user_id_from_address($link2, $address));
         if ($nickname != "" && $nickname != $address) {
             $address = "<A HREF=\"userstats.php/{$address}\">{$nickname}<BR><FONT SIZE=\"-3\">({$address})</FONT></A>";
         } else {
             $address = "<A HREF=\"userstats.php/{$address}\">{$address}</A>";
         }
     } else {
         $address = "(Unknown users)";
     }
     if ($oe == 1) {
Ejemplo n.º 5
0
function block_table_row($row, $isodd)
{
    $blocks_row = "";
    if (isset($row["acceptedshares"])) {
        $luck = 100 * ($row["network_difficulty"] / $row["acceptedshares"]);
    } else {
        $luck = 0;
    }
    if ($luck > 9000) {
        $luck = "<A STYLE=\"color:#3B4033;font-weight:normal;text-decoration:none;cursor:default\" HREF=\"9000.php\">&gt;9,000%</A>";
    } else {
        $luck = number_format(round($luck, 1), 1) . "%";
    }
    $roundstart = substr($row["roundstart"], 0, 19);
    if ($row["confirmations"] >= 120) {
        $confs = "Confirmed";
    } else {
        if ($row["confirmations"] == 0) {
            $confs = "Stale";
            $luck = "n/a";
            $roundstart = "<SMALL>(" . substr($row["time"], 0, 19);
            $roundstart .= ")</SMALL>";
        } else {
            $confs = $row["confirmations"] . " of 120";
        }
    }
    $dbid = $row["blockid"];
    if ($row["confirmations"] == 0) {
        $blocks_row .= "<TR id=\"blockrow{$dbid}\" BGCOLOR=\"#FFDFDF\" class=\"{$isodd}" . "blockorphan\">";
    } else {
        if ($row["confirmations"] >= 120) {
            $blocks_row .= "<TR id=\"blockrow{$dbid}\" class=\"{$isodd}" . "blockconfirmed\">";
        } else {
            $rowcolour = $isodd ? array(0xd3, 0xeb, 0xe3) : array(0xeb, 0xed, 0xe9);
            $uccolour = array(0xff, 0x7f, 0);
            $rowcolour = blend_colours($uccolour, $rowcolour, $row["confirmations"] / 120);
            $blocks_row .= "<TR class=\"{$isodd}" . "blockunconfirmed\" id=\"blockrow{$dbid}\" style=\"background-color: " . csscolour($rowcolour) . "\">";
        }
    }
    $blocks_row .= "<TD sorttable_customkey=\"" . $row["age"] . "\" style=\"font-size: 0.9em;\">" . prettyDuration($row["age"], false, 1) . "</TD>";
    $blocks_row .= "<TD style=\"font-size: 0.8em;\">" . $roundstart . "</TD>";
    if (isset($row["duration"])) {
        list($seconds, $minutes, $hours) = extractTime($row["duration"]);
        $seconds = sprintf("%02d", $seconds);
        $minutes = sprintf("%02d", $minutes);
        $hours = sprintf("%02d", $hours);
        $blocks_row .= "<td sorttable_customkey=\"" . $row["duration"] . "\" style=\"width: 1.5em;  text-align: right;\">{$hours}:{$minutes}:{$seconds}</td>";
        $hashrate = $row["acceptedshares"] * 4294967296 / $row["duration"];
        $hashratenum = $hashrate;
        $hashrate = prettyHashrate($hashrate);
        $hashrate = substr($hashrate, 0, -2);
        $percentofnetwork = $hashratenum / ($row["network_difficulty"] * 7158278.82667);
        $percentofnetwork = sprintf("%.2f%% of network", $percentofnetwork * 100);
        $hashrate = "<span title=\"{$percentofnetwork}\">{$hashrate}</span>";
    } else {
        $blocks_row .= "<td style=\"text-align: right;\">n/a</td>";
        $hashrate = "n/a";
    }
    $blocks_row .= "<TD style=\"text-align: right;\" sorttable_customkey=\"" . $row["acceptedshares"] . "\">" . ($row["acceptedshares"] > 0 ? number_format($row["acceptedshares"]) : "n/a") . "</TD>";
    $blocks_row .= "<TD style=\"text-align: right;\" sorttable_customkey=\"" . $row["network_difficulty"] . "\">" . formatSI($row["network_difficulty"], 2) . "</TD>";
    $blocks_row .= "<TD style=\"text-align: right;\">" . $luck . "</TD>";
    $hashratenum = sprintf("%.0f", $hashratenum);
    $blocks_row .= "<TD style=\"text-align: right; font-size: 0.9em;\" sorttable_customkey=\"" . $hashratenum . "\" >" . $hashrate . "</TD>";
    $blocks_row .= "<TD class=\"blockconfirms\" style=\"text-align: right;\">" . $confs . "</TD>";
    if (isset($row['keyhash'])) {
        $fulladdress = \Bitcoin::hash160ToAddress(bits2hex($row['keyhash']));
        $address = substr($fulladdress, 0, 10) . "...";
    } else {
        $fulladdress = "";
        $address = "(Unknown user)";
    }
    $blocks_row .= "<TD style=\"font-family:monospace;\"><A HREF=\"userstats.php/" . $fulladdress . "\">" . $address . "</A></TD>";
    if (isset($row["height"]) && $row["height"] > 0) {
        $ht = number_format($row["height"]);
    } else {
        $ht = "n/a";
    }
    $blocks_row .= "<TD style=\"text-align: right;\">{$ht}</TD>";
    $nicehash = "..." . substr($row["blockhash"], 46, 18);
    $blocks_row .= "<TD style=\"font-family:monospace;\"><A HREF=\"blockinfo.php/" . $row["blockhash"] . "\">" . $nicehash . "</A></TD>";
    $blocks_row .= "</TR>";
    return $blocks_row;
}
Ejemplo n.º 6
0
    exit;
}
$givenuser = substr($_SERVER['PATH_INFO'], 1, strlen($_SERVER['PATH_INFO']) - 1);
$bits = hex2bits(\Bitcoin::addressToHash160($givenuser));
$link = pg_pconnect("dbname={$psqldb} user={$psqluser} password='******' host={$psqlhost}");
$user_id = get_user_id_from_address($link, $givenuser);
if (!$user_id) {
    print "Error: Username {$givenuser} not found in database.  Please try again later.";
    exit;
}
if ($cppsrbjsondec = apc_fetch('cppsrb_json')) {
} else {
    $cppsrbjson = file_get_contents("/var/lib/eligius/{$serverid}/cppsrb.json");
    $cppsrbjsondec = json_decode($cppsrbjson, true);
    apc_store('cppsrb_json', $cppsrbjsondec, 60);
}
$mycppsrb = $cppsrbjsondec[$givenuser];
$globalccpsrb = $cppsrbjsondec[""];
$latest_chunk = $globalccpsrb['share_log_top_chunk'];
#var_export ($globalccpsrb['share_log_top_chunk']);
#print "<PRE>";
#var_dump($mycppsrb);
$my_shares = $mycppsrb["shares"];
$my_share_log = $mycppsrb["share_log"];
#var_dump($my_shares);
#var_dump($my_share_log);
print "Insta-hashrate for {$givenuser} - ";
print "64 second: " . prettyHashrate($my_shares[64] * 4294967296 / 64) . " - ";
print "128 second: " . prettyHashrate($my_shares[128] * 4294967296 / 128) . " - ";
print "256 second: " . prettyHashrate($my_shares[256] * 4294967296 / 256);