Skip to content

Commit

Permalink
Merge pull request #59 from marcdeb1/confirmations_fix
Browse files Browse the repository at this point in the history
Confirmations fix
  • Loading branch information
tzarebczan authored Mar 26, 2019
2 parents 1b13f27 + a0dac9c commit 6054ddc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
lbryexplorer.zip
lbryexplorer.komodoproject
.komodotools
/.gtm/
12 changes: 11 additions & 1 deletion src/Controller/MainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,11 @@ public function blocks($height = null) {

// Get the basic block transaction info
$txs = $this->Transactions->find()->select(['Transactions.id', 'Transactions.value', 'Transactions.input_count', 'Transactions.output_count', 'Transactions.hash', 'Transactions.version'])->where(['Transactions.block_hash_id' => $block->hash])->toArray();
$last_block = $this->Blocks->find()->select(['height'])->order(['height' => 'desc'])->first();
$confirmations = $last_block->height - $block->height + 1;
$this->set('block', $block);
$this->set('blockTxs', $txs);
$this->set('confirmations', $confirmations);
}
}

Expand All @@ -349,7 +352,14 @@ public function tx($hash = null) {
}

$block = $this->Blocks->find()->select(['confirmations', 'height'])->where(['hash' => $tx->block_hash_id])->first();
$confirmations = $block->confirmations;
$confirmations = 0;
if($tx->block_hash_id == 'MEMPOOL') {
$confirmations = 0;
}
else {
$last_block = $this->Blocks->find()->select(['height'])->order(['height' => 'desc'])->first();
$confirmations = $last_block->height - $block->height + 1;
}
$inputs = $this->Inputs->find()->where(['transaction_id' => $tx->id])->order(['prevout_n' => 'asc'])->toArray();
foreach($inputs as $input) {
$inputAddresses = $this->Addresses->find()->select(['id', 'address'])->where(['id' => $input->input_address_id])->toArray();
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Main/blocks.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<div class="label half-width">Confirmations</div>

<div class="value half-width"><?php echo $block->bits ?></div>
<div class="value half-width"><?php echo number_format($block->confirmations, 0, '', ',') ?></div>
<div class="value half-width"><?php echo $confirmations ?></div>

<div class="clear spacer"></div>

Expand Down
10 changes: 1 addition & 9 deletions src/Template/Main/index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,6 @@
foreach ($recentClaims as $claim):
$idx++;
$autoThumbText = $claim->getAutoThumbText();
$link = $claim->name;
$rawLink = $claim->name;
if (isset($claim->publisher)) {
$link = urlencode($claim->publisher) . '/' . $link;
$rawLink = $claim->publisher . '/' . $link;
}
$link = 'lbry://' . $link;
$rawLink = 'lbry://' . $rawLink;

// content type
$ctTag = $claim->getContentTag();
Expand All @@ -219,7 +211,7 @@

<div class="metadata">
<div class="title" title="<?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : ''); ?>"><?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : '<em>No Title</em>') ?></div>
<div class="link" title="<?php echo $rawLink ?>"><a href="<?php echo $link ?>"><?php echo $rawLink ?></a></div>
<div class="link" title="<?php echo $claim->getLbryLink() ?>"><a href="<?php echo $claim->getLbryLink() ?>"><?php echo $claim->getLbryLink() ?></a></div>

<div class="clear"></div>
<?php if ($claim->claim_type == 2 && strlen(trim($claim->description)) > 0): ?>
Expand Down

0 comments on commit 6054ddc

Please sign in to comment.