From 11adc88651e0fbd49fdc924801a3b39348beec80 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Tue, 21 Jan 2014 10:09:51 -0300 Subject: [PATCH 1/5] check if mongod is running. show a message. --- server.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server.js b/server.js index 1f49503..33f6248 100644 --- a/server.js +++ b/server.js @@ -24,6 +24,16 @@ var express = require('express'), var config = require('./config/config'); //Bootstrap db connection +// If mongod is running +mongoose.connection.on('open', function (ref) { + console.log('Connected to mongo server.'); +}); +// If mongod is not running +mongoose.connection.on('error', function (err) { + console.log('Could not connect to mongo server!'); + console.log(err); +}); + mongoose.connect(config.db); //Bootstrap models From 56dc130b4fc9a1c48a99889e922fe030c62657be Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Tue, 21 Jan 2014 10:46:19 -0300 Subject: [PATCH 2/5] show for 2 sec a box message if not found block --- public/js/controllers/search.js | 5 ++++- public/views/header.html | 14 +++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/public/js/controllers/search.js b/public/js/controllers/search.js index e1299dc..1dd2c58 100644 --- a/public/js/controllers/search.js +++ b/public/js/controllers/search.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('insight.search').controller('SearchController', - function ($scope, $routeParams, $location, Global, Block, Transaction, Address) { + function ($scope, $routeParams, $location, $timeout, Global, Block, Transaction, Address) { $scope.global = Global; $scope.search = function() { @@ -26,6 +26,9 @@ angular.module('insight.search').controller('SearchController', $location.path('address/' + q); }, function () { //address not found, fail :( $scope.badQuery = true; + $timeout(function() { + $scope.badQuery = false; + }, 2000); $scope.q = q; }); }); diff --git a/public/views/header.html b/public/views/header.html index 6d12e44..bcc2d55 100755 --- a/public/views/header.html +++ b/public/views/header.html @@ -11,17 +11,18 @@ From ef109e32516a573fce405993ea5ff4525c96f04e Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Tue, 21 Jan 2014 10:55:35 -0300 Subject: [PATCH 3/5] search by height of block --- public/js/controllers/search.js | 48 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/public/js/controllers/search.js b/public/js/controllers/search.js index 1dd2c58..07af17b 100644 --- a/public/js/controllers/search.js +++ b/public/js/controllers/search.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('insight.search').controller('SearchController', - function ($scope, $routeParams, $location, $timeout, Global, Block, Transaction, Address) { + function ($scope, $routeParams, $location, $timeout, Global, Block, Transaction, Address, BlockByHeight) { $scope.global = Global; $scope.search = function() { @@ -10,28 +10,34 @@ angular.module('insight.search').controller('SearchController', $scope.badQuery = false; $scope.q = ''; - Block.get({ - blockHash: q - }, function() { - $location.path('block/' + q); - }, function () { //block not found, search on TX - Transaction.get({ - txId: q + BlockByHeight.get({ + blockHeight: q + }, function(hash) { + $location.path('/block/' + hash.blockHash); + }, function() { // block by height not found + Block.get({ + blockHash: q }, function() { - $location.path('tx/' + q); - }, function () { //tx not found, search on Address - Address.get({ - addrStr: q + $location.path('block/' + q); + }, function () { //block not found, search on TX + Transaction.get({ + txId: q }, function() { - $location.path('address/' + q); - }, function () { //address not found, fail :( - $scope.badQuery = true; - $timeout(function() { - $scope.badQuery = false; - }, 2000); - $scope.q = q; - }); - }); + $location.path('tx/' + q); + }, function () { //tx not found, search on Address + Address.get({ + addrStr: q + }, function() { + $location.path('address/' + q); + }, function () { //address not found, fail :( + $scope.badQuery = true; + $timeout(function() { + $scope.badQuery = false; + }, 2000); + $scope.q = q; + }); + }); + }); }); }; From 9337196233824175e7b91048ccb7911f3b97a317 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 21 Jan 2014 10:56:09 -0300 Subject: [PATCH 4/5] fix conflics --- app/views/includes/foot.jade | 1 - public/js/controllers/footer.js | 16 --------- public/js/controllers/status.js | 11 ++++++ public/js/controllers/transactions.js | 17 ++++++++-- public/views/header.html | 24 +++++++------ public/views/transaction.html | 2 +- public/views/transaction/tx.html | 49 +++++++++++---------------- 7 files changed, 59 insertions(+), 61 deletions(-) delete mode 100644 public/js/controllers/footer.js diff --git a/app/views/includes/foot.jade b/app/views/includes/foot.jade index 735e8c0..4a14f1a 100755 --- a/app/views/includes/foot.jade +++ b/app/views/includes/foot.jade @@ -36,7 +36,6 @@ script(type='text/javascript', src='/js/services/socket.js') //Application Controllers script(type='text/javascript', src='/js/controllers/index.js') script(type='text/javascript', src='/js/controllers/header.js') -script(type='text/javascript', src='/js/controllers/footer.js') script(type='text/javascript', src='/js/controllers/blocks.js') script(type='text/javascript', src='/js/controllers/transactions.js') script(type='text/javascript', src='/js/controllers/address.js') diff --git a/public/js/controllers/footer.js b/public/js/controllers/footer.js deleted file mode 100644 index e9d5c42..0000000 --- a/public/js/controllers/footer.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -angular.module('insight.system').controller('FooterController', - function ($scope, Global, Status) { - $scope.global = Global; - - $scope.getFooter = function() { - Status.get({ - q: 'getInfo' - }, function(d) { - $scope.info = d.info; - }); - }; - -}); - diff --git a/public/js/controllers/status.js b/public/js/controllers/status.js index 019c04d..f1fdded 100644 --- a/public/js/controllers/status.js +++ b/public/js/controllers/status.js @@ -23,6 +23,17 @@ angular.module('insight.status').controller('StatusController', $scope.getSync = function() { Sync.get({}, function(sync) { $rootScope.syncError = null; + + if (sync.blocksToSync > sync.syncedBlocks ) { + sync.message = 'Blocks to sync: ' + (sync.blocksToSync - sync.syncedBlocks); + sync.tooltip = 'Skipped blocks:' + sync.skipped_blocks; + } + else { + sync.message = 'On sync'; + sync.tooltip = ''; + } + + $scope.sync = sync; }, function(e) { $rootScope.syncError = 'Could not get sync information' + e; diff --git a/public/js/controllers/transactions.js b/public/js/controllers/transactions.js index d33e250..28efee2 100644 --- a/public/js/controllers/transactions.js +++ b/public/js/controllers/transactions.js @@ -14,19 +14,29 @@ angular.module('insight.transactions').controller('transactionsController', var ret = []; var tmp = {}; + var u=0; // TODO multiple output address // for(var i=0; i < l; i++) { + var notAddr = false; + + // non standard input + if (items[i].scriptSig && !items[i].addr) { + items[i].addr = 'Unparsed address [' + u++ + ']'; + items[i].notAddr = true; + notAddr = true; + } + // non standard output if (items[i].scriptPubKey && items[i].scriptPubKey.addresses.length > 1) { - item[i].addr = items[i].scriptPubKey.addresses.join(','); + items[i].addr = items[i].scriptPubKey.addresses.join(','); ret.push(items[i]); continue; } - var addr = items[i].addr || - (items[i].scriptPubKey && items[i].scriptPubKey.addresses[0] ); + var addr = items[i].addr || (items[i].scriptPubKey && items[i].scriptPubKey.addresses[0] ); + if (!tmp[addr]) { tmp[addr] = {}; tmp[addr].valueSat = 0; @@ -37,6 +47,7 @@ angular.module('insight.transactions').controller('transactionsController', tmp[addr].valueSat += items[i].valueSat; tmp[addr].value = tmp[addr].valueSat / 100000000; tmp[addr].items.push(items[i]); + tmp[addr].notAddr = notAddr; tmp[addr].count++; } diff --git a/public/views/header.html b/public/views/header.html index bcc2d55..38f0c84 100755 --- a/public/views/header.html +++ b/public/views/header.html @@ -23,16 +23,20 @@
No matching records found!
-
- - Status: On Sync - - - Connections: {{info.connections}} - - - Height: {{info.blocks}} - +
+ + + {{sync.message}} + + + + + Connections: {{info.connections}} + + + Height: {{info.blocks}} + +
diff --git a/public/views/transaction.html b/public/views/transaction.html index 4e325be..3970353 100644 --- a/public/views/transaction.html +++ b/public/views/transaction.html @@ -23,7 +23,7 @@ Block - + {{tx.blockhash}} diff --git a/public/views/transaction/tx.html b/public/views/transaction/tx.html index c33a0f6..76be786 100644 --- a/public/views/transaction/tx.html +++ b/public/views/transaction/tx.html @@ -1,6 +1,14 @@
{{tx.txid}} + + + + + + {{tx.time * 1000 | date:'medium'}} + +
@@ -13,42 +21,32 @@
-
@@ -58,17 +56,18 @@
-
+
- {{address}} + {{vout.addr}} + {{address}}

{{vout.value}} BTC

- From 0e92ef0100910cedc9681335bf5540c455447eda Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Tue, 21 Jan 2014 11:28:30 -0300 Subject: [PATCH 5/5] a warning --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 33f6248..365ff28 100644 --- a/server.js +++ b/server.js @@ -25,7 +25,7 @@ var config = require('./config/config'); //Bootstrap db connection // If mongod is running -mongoose.connection.on('open', function (ref) { +mongoose.connection.on('open', function () { console.log('Connected to mongo server.'); }); // If mongod is not running