Example #1
0
    }
    return (double) $array['rhs'];
}
try {
    $rate = exchangeRate(1, 'usd', 'aud');
    $settings->setsetting('aud', $rate);
} catch (Exception $exception) {
    // log $exception->getMessage()
    echo 'Due to technical difficulties, we couldn\'t get the exchange rate';
}
$lastPaidBlockQ = mysql_query("select blockNumber from rounds where paid = 1 order by blockNumber desc limit 1");
if ($lastPaidBlock = mysql_fetch_object($lastPaidBlockQ)) {
    $block = $lastPaidBlock->blockNumber;
    mysql_query("delete from shares_history where blockNumber < {$block} and (upstream_result != 'Y' or upstream_result is null) limit 500000") or die("Error clearing shares: " . mysql_error());
}
$difficulty = $bitcoinController->query("getdifficulty");
$hashrate = $settings->getsetting('currenthashrate');
$time_to_find = CalculateTimePerBlock($difficulty, $hashrate);
$intpart = floor($time_to_find);
$fraction = $time_to_find - $intpart;
// results in 0.75
$minutes = number_format($fraction * 60, 0);
$timetofind = "" . number_format($time_to_find, 0) . " Hours " . $minutes . " Minutes";
$result = mysql_query("SELECT blockNumber, confirms, timestamp FROM networkBlocks WHERE confirms > 0 ORDER BY blockNumber DESC LIMIT 1");
$resultrow = mysql_fetch_object($result);
$time_last_found = $resultrow->timestamp;
$now = new DateTime("now");
$hours_diff = ($now->getTimestamp() - $time_last_found) / 3600;
$time_last_found_out = floor($hours_diff) . " Hours " . $hours_diff * 60 % 60 . " Minutes";
$settings->setsetting('timetofind', $timetofind);
$settings->setsetting('time_last_found_out', $time_last_found_out);
Example #2
0
echo "<tr><td class=\"leftheader\">Current Users Mining</td><td>" . number_format($hashcount) . "</td></tr>";
echo "<tr><td class=\"leftheader\">Current Total Miners</td><td>" . number_format($stats->currentworkers()) . "</td></tr>";
echo "<tr><td class=\"leftheader\">Current Block</td><td><a href=\"http://blockexplorer.com/b/" . $current_block_no . "\">";
echo number_format($current_block_no) . "</a></td></tr>";
echo "<tr><td class=\"leftheader\">Current Difficulty</th><td><a href=\"http://dot-bit.org/tools/nextDifficulty.php\">" . number_format($show_difficulty) . "</a></td></tr>";
$lastblocks = $stats->lastwinningblocks($last_no_blocks_found);
$show_time_since_found = false;
$time_last_found;
if (count($lastblocks) > 0) {
    $found_block_no = $lastblocks[0][1];
    $confirm_no = $lastblocks[0][2];
    echo "<tr><td class=\"leftheader\">Last Block Found</td><td><a href=\"http://blockexplorer.com/b/" . $found_block_no . "\">" . number_format($found_block_no) . "</a></td></tr>";
    $time_last_found = $lastblocks[0][3];
    $show_time_since_found = true;
}
$time_to_find = CalculateTimePerBlock($difficulty, $stats->currenthashrate());
// change 25.75 hours to 25:45 hours
$intpart = floor($time_to_find);
$fraction = $time_to_find - $intpart;
// results in 0.75
$minutes = number_format($fraction * 60, 0);
echo "<tr><td class=\"leftheader\">Est. Time To Find Block</td><td>" . number_format($time_to_find, 0) . " Hours " . $minutes . " Minutes</td></tr>";
$now = new DateTime("now");
if (isset($time_last_found)) {
    $hours_diff = ($now->getTimestamp() - $time_last_found) / 3600;
} else {
    $hours_diff = 0;
}
if ($hours_diff < $time_to_find) {
    $time_last_found_out = "<span class=\"green\">";
} elseif ($hours_diff * 2 > $time_to_find) {