diff --git a/app/controllers/blocks.js b/app/controllers/blocks.js index b41b67f..a0d2d1e 100644 --- a/app/controllers/blocks.js +++ b/app/controllers/blocks.js @@ -3,9 +3,10 @@ /** * Module dependencies. */ -var mongoose = require('mongoose'), - Block = mongoose.model('Block'), - common = require('./common'); +var mongoose = require('mongoose'), + Block = mongoose.model('Block'), + common = require('./common'), + async = require('async'); /** @@ -47,6 +48,16 @@ exports.blockindex = function(req, res, next, height) { }); }; +var getBlock = function(blockhash, cb) { + Block.fromHashWithInfo(blockhash, function(err, block) { + if (err) { + console.log(err); + return cb(err); + } + return cb(err, block.info); + }); +}; + /** * List of blocks by date */ @@ -89,13 +100,20 @@ exports.list = function(req, res) { if (err) { res.status(500).send(err); } else { - res.jsonp({ - blocks: blocks, - pagination: { - next: next, - prev: prev, - current: dateStr - } + var blockshash = []; + for(var i=0;i parseInt(TRANSACTION_DISPLAYED) - 1) { $scope.txs.pop(); } - $scope.txs.unshift(tx); + getTransaction(txStr); }); socket.on('block', function(block) { + var blockHash = block.hash.toString(); console.log('Block received! ' + JSON.stringify(block)); - if ($scope.blocks.length === BLOCKS_DISPLAYED) { - $scope.blocks.pop(); - } - $scope.blocks.unshift(block); + if (parseInt($scope.blocks.length) > parseInt(BLOCKS_DISPLAYED) - 1) { + $scope.blocks.pop(); + } + getBlock(blockHash); }); $scope.human_since = function(time) { @@ -38,12 +56,13 @@ angular.module('insight.system').controller('IndexController', limit: BLOCKS_DISPLAYED }, function(res) { $scope.blocks = res.blocks; + $scope.blocksLength = res.lenght; }); - Transactions.query({ + Transactions.get({ limit: TRANSACTION_DISPLAYED - }, function(txs) { - $scope.txs = txs; + }, function(res) { + $scope.txs = res.txs; }); }; diff --git a/public/views/blocks/list.html b/public/views/blocks/list.html index abdcf85..40b90fc 100644 --- a/public/views/blocks/list.html +++ b/public/views/blocks/list.html @@ -11,33 +11,47 @@

{{pagination.current}}

- ← {{pagination.prev}} + ← {{pagination.prev}} {{pagination.next}} →
-
+
- +
- - + + + + + - - - + + + + + + +
HashSolved atHeightTimestampTransactionsSizeConfirmations
{{block.hash}}{{block.time * 1000 | date:'medium'}}
Waiting for blocks...
+ {{b.height}} + {{b.time * 1000 | date:'medium'}}{{b.tx.length}}{{b.size}}{{b.confirmations}}
+

No blocks yet.

diff --git a/public/views/header.html b/public/views/header.html index baf6f77..b9f2a51 100755 --- a/public/views/header.html +++ b/public/views/header.html @@ -35,7 +35,7 @@ Conn: {{info.connections}} - Height: {{info.blocks}} + Height: {{totalBlocks || info.blocks}} diff --git a/public/views/index.html b/public/views/index.html index 0e4de2b..6a3fdf1 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -4,21 +4,57 @@
-
-

New transactions

- +
+

Blocks

+ + + + + + + + + + + + + + + + + + + + +
HeightAgeTransactionsSizeConfirmations
Waiting for blocks...
+ {{b.height}} + {{human_since(b.time)}}{{b.tx.length}}{{b.size}}{{b.confirmations}}
-
-

New blocks

- + +
+

Transactions

+ + + + + + + + + + + + + + + + + + + +
HashAgeValue OutSize
Waiting for transactions...
+ {{tx.txid}} + {{human_since(tx.time)}}{{tx.valueOut}}{{tx.size}}