From 5c5c7924af2d2d2295b26baf242b42cc54ee9bf9 Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Mon, 25 Mar 2019 23:23:08 +0100 Subject: [PATCH] Confirmations number fix --- src/Controller/MainController.php | 6 +++++- src/Template/Main/blocks.ctp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 7419653..4716a7c 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -328,8 +328,11 @@ class MainController extends AppController { // 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); } } @@ -349,7 +352,8 @@ class MainController extends AppController { } $block = $this->Blocks->find()->select(['confirmations', 'height'])->where(['hash' => $tx->block_hash_id])->first(); - $confirmations = $block->confirmations; + $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(); diff --git a/src/Template/Main/blocks.ctp b/src/Template/Main/blocks.ctp index 45c3b8d..9dc09e8 100644 --- a/src/Template/Main/blocks.ctp +++ b/src/Template/Main/blocks.ctp @@ -54,7 +54,7 @@
Confirmations
bits ?>
-
confirmations, 0, '', ',') ?>
+