pool/web/yaamp/modules/site/results/found_results.php
Tanguy Pruvot cbe55a3a84 Squashed commit for segwit support:
commit c59abe5d203fabdabcca81ff5f9c6ff133cfae3b
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Tue Nov 28 11:13:52 2017 +0100

    segwit: show a segwit icon on blocks history

    + remove some inline styles...

commit b4a8639370e6837ebc5a2047e7c334e9f931abfc
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Tue Nov 28 09:55:40 2017 +0100

    segwit: cleanup + masternode case

    tested ok with BSD (block 400996), and with real BTX segwit txs (block 90958)

    also ok on VTC and GRS

commit 926dbd11757ebff7f7d4930266de9b9061c8ab16
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Sat Nov 25 18:41:01 2017 +0100

    sql: add segwit fields, and ui config

    and fill block segwit field if it contains segwit txs,
    an icon is added in the dashboard "last blocks" for these blocks

commit 0b13bf55e9dd1d2229d188f0f8382b27642b20da
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Sat Nov 25 13:47:20 2017 +0100

    segwit: include commitment in coinbase + .conf toggle

    tested ok on BTX, GRS and VTC with normal txs, but the commitment merkle hash maybe need some more love...

    so, to prevent useless bigger blocks, only generate segwit commitment if a segwit tx is present in mempool

    to check with real segwit txs... not seen any yet..

commit b508bc87943d9e426cda994c2f53c16c11e8d4c3
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Thu Mar 2 11:18:34 2017 +0100

    segwit: prepare the witness data, but disabled

    need more test, may affect the coinbase merkle and the miners...

commit 19bd3a83b9ddddd8b5ed4b7a1bdf8cf8c233e346
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Thu Mar 2 10:30:29 2017 +0100

    stratum: handle and auto toggle segwit if supported
2017-11-28 11:55:20 +01:00

127 lines
3.8 KiB
PHP

<?php
function WriteBoxHeader($title)
{
echo "<div class='main-left-box'>";
echo "<div class='main-left-title'>$title</div>";
echo "<div class='main-left-inner'>";
}
$showrental = (bool) YAAMP_RENTAL;
$algo = user()->getState('yaamp-algo');
$count = getparam('count');
$count = $count? $count: 50;
WriteBoxHeader("Last $count Blocks ($algo)");
$criteria = new CDbCriteria();
$criteria->condition = "t.category NOT IN ('stake','generated')";
$criteria->condition .= " AND IFNULL(coin.visible,1)=1"; // ifnull for rental
if($algo != 'all') {
$criteria->condition .= " AND t.algo=:algo";
$criteria->params = array(':algo'=>$algo);
}
$criteria->limit = $count;
$criteria->order = 't.time DESC';
$db_blocks = getdbolistWith('db_blocks', 'coin', $criteria);
echo <<<EOT
<style type="text/css">
span.block { padding: 2px; display: inline-block; text-align: center; min-width: 75px; border-radius: 3px; }
span.block.new { color: white; background-color: #ad4ef0; }
span.block.orphan { color: white; background-color: #d9534f; }
span.block.immature { color: white; background-color: #f0ad4e; }
span.block.confirmed { color: white; background-color: #5cb85c; }
b.row a { font-size: 10pt; }
.ssrow td.row { font-size: .8em; }
td.right { text-align: right; }
</style>
<table class="dataGrid2">
<thead>
<tr>
<td></td>
<th>Name</th>
<th align="right">Amount</th>
<th align="right">Difficulty</th>
<th align="right">Block</th>
<th align="right">Time</th>
<th align="right">Status</th>
</tr>
</thead>
EOT;
foreach($db_blocks as $db_block)
{
$d = datetoa2($db_block->time);
if(!$db_block->coin_id)
{
if (!$showrental)
continue;
$reward = bitcoinvaluetoa($db_block->amount);
echo '<tr class="ssrow">';
echo '<td width="18px"><img width="16px" src="/images/btc.png"/></td>';
echo '<td class="row"><b>Rental</b> ('.$db_block->algo.')</td>';
echo '<td class="row right"><b>'.$reward.' BTC</b></td>';
echo '<td class="row right"></td>';
echo '<td class="row right"></td>';
echo '<td class="row right">'.$d.' ago</td>';
echo '<td class="row right">';
echo '<span class="block confirmed">Confirmed</span>';
echo '</td>';
echo '</tr>';
continue;
}
$reward = round($db_block->amount, 3);
$coin = $db_block->coin ? $db_block->coin : getdbo('db_coins', $db_block->coin_id);
$difficulty = Itoa2($db_block->difficulty, 3);
$height = number_format($db_block->height, 0, '.', ' ');
$link = $coin->createExplorerLink($coin->name, array('hash'=>$db_block->blockhash));
$flags = $db_block->segwit ? '&nbsp;<img src="/images/ui/segwit.png" height="8px" valign="center" title="segwit"/>' : '';
echo '<tr class="ssrow">';
echo '<td width="18px"><img width="16px" src="'.$coin->image.'"></td>';
echo '<td class="row"><b class="row">'.$link.'</b> ('.$coin->algo.')'.$flags.'</td>';
echo '<td class="row right"><b>'.$reward.' '.$coin->symbol_show.'</b></td>';
echo '<td class="row right" title="found '.$db_block->difficulty_user.'">'.$difficulty.'</td>';
echo '<td class="row right">'.$height.'</td>';
echo '<td class="row right">'.$d.' ago</td>';
echo '<td class="row right">';
if($db_block->category == 'orphan')
echo '<span class="block orphan">Orphan</span>';
else if($db_block->category == 'immature') {
$eta = '';
if ($coin->block_time && $coin->mature_blocks) {
$t = (int) ($coin->mature_blocks - $db_block->confirmations) * $coin->block_time;
$eta = "ETA: ".sprintf('%dh %02dmn', ($t/3600), ($t/60)%60);
}
echo '<span class="block immature" title="'.$eta.'">Immature ('.$db_block->confirmations.')</span>';
}
else if($db_block->category == 'generate')
echo '<span class="block confirmed">Confirmed</span>';
else if($db_block->category == 'new')
echo '<span class="block new">New</span>';
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "<br></div></div><br>";