update confirmations calculation on block list page

This commit is contained in:
Akinwale Ariwodola 2018-07-26 12:22:51 +01:00
parent b91b3681d3
commit a8a956f2bc
2 changed files with 6 additions and 2 deletions

View file

@ -402,7 +402,11 @@ class MainController extends AppController {
} }
$offset = ($page - 1) * $pageLimit; $offset = ($page - 1) * $pageLimit;
$blocks = $this->Blocks->find()->offset($offset)->limit($pageLimit)->order(['Height' => 'DESC'])->toArray(); $currentBlock = $this->Blocks->find()->select(['Height'])->order(['Height' => 'DESC'])->first();
$blocks = $this->Blocks->find()->select(
['Height', 'Difficulty', 'TransactionHashes', 'BlockSize', 'Nonce', 'BlockTime']
)->offset($offset)->limit($pageLimit)->order(['Height' => 'DESC'])->toArray();
$this->set('currentBlock', $currentBlock);
$this->set('blocks', $blocks); $this->set('blocks', $blocks);
$this->set('pageLimit', $pageLimit); $this->set('pageLimit', $pageLimit);
$this->set('numPages', $numPages); $this->set('numPages', $numPages);

View file

@ -412,7 +412,7 @@
<tr> <tr>
<td class="right"><a href="/blocks/<?php echo $block->Height ?>"><?php echo $block->Height ?></a></td> <td class="right"><a href="/blocks/<?php echo $block->Height ?>"><?php echo $block->Height ?></a></td>
<td class="pad-left"><?php echo number_format($block->Difficulty, 8, '.', '') ?></td> <td class="pad-left"><?php echo number_format($block->Difficulty, 8, '.', '') ?></td>
<td class="right"><?php echo number_format($block->Confirmations, 0, '', ',') ?></td> <td class="right"><?php echo number_format((($currentBlock->Height - $block->Height) + 1), 0, '', ',') ?></td>
<td class="right"><?php echo count(json_decode($block->TransactionHashes)) ?></td> <td class="right"><?php echo count(json_decode($block->TransactionHashes)) ?></td>
<td class="right"><?php echo round($block->BlockSize / 1024, 2) . 'KB' ?></td> <td class="right"><?php echo round($block->BlockSize / 1024, 2) . 'KB' ?></td>
<td class="right pad-left"><?php echo $block->Nonce ?></td> <td class="right pad-left"><?php echo $block->Nonce ?></td>