From 25b6011b7c18963c339a34131cdeb36e528ff956 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Feb 2014 17:00:26 -0300 Subject: [PATCH 1/2] improve error messages + fix server error display --- README.md | 7 ++- public/src/js/controllers/connection.js | 81 ++++++++++++------------- public/views/includes/connection.html | 4 +- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index edeab930..14dad903 100644 --- a/README.md +++ b/README.md @@ -136,11 +136,16 @@ A REST API is provided at /api. The entry points are: /api/txs/?address=mmhmMNfBiZZ37g1tgg2t8DDbNoEdqKVxAL ``` -### Sync status +### Historic blockchain data sync status ``` /api/sync ``` +### Live network p2p data sync status +``` + /api/peer +``` + ## Web Socket API The web socket API is served using [socket.io](http://socket.io) at: ``` diff --git a/public/src/js/controllers/connection.js b/public/src/js/controllers/connection.js index 2c3198a4..e5dae0bc 100644 --- a/public/src/js/controllers/connection.js +++ b/public/src/js/controllers/connection.js @@ -1,51 +1,50 @@ 'use strict'; angular.module('insight.connection').controller('ConnectionController', -function($scope, $window, Status, getSocket, PeerSync) { + function($scope, $window, Status, getSocket, PeerSync) { - // Set initial values - $scope.apiOnline = true; - $scope.serverOnline = true; - $scope.clienteOnline = true; - - var socket = getSocket($scope); - - // Check for the node server connection - socket.on('disconnect', function() { - $scope.serverOnline = false; - }); - - socket.on('connect', function() { + // Set initial values + $scope.apiOnline = true; $scope.serverOnline = true; - }); + $scope.clienteOnline = true; - // Check for the api connection - $scope.getConnStatus = function() { - PeerSync.get({}, - function(peer) { - $scope.apiOnline = peer.connected; - }, - function() { - $scope.apiOnline = false; + var socket = getSocket($scope); + + // Check for the node server connection + socket.on('connect', function() { + $scope.serverOnline = true; + socket.on('disconnect', function() { + $scope.serverOnline = false; + }); }); - }; - socket.emit('subscribe', 'sync'); - socket.on('status', function(sync) { + // Check for the api connection + $scope.getConnStatus = function() { + PeerSync.get({}, + function(peer) { + $scope.apiOnline = peer.connected; + }, + function() { + $scope.apiOnline = false; + }); + }; + + socket.emit('subscribe', 'sync'); + socket.on('status', function(sync) { $scope.apiOnline = (sync.status !== 'aborted' && sync.status !== 'error'); + }); + + // Check for the client conneciton + $window.addEventListener('offline', function() { + $scope.$apply(function() { + $scope.clienteOnline = false; + }); + }, true); + + $window.addEventListener('online', function() { + $scope.$apply(function() { + $scope.clienteOnline = true; + }); + }, true); + }); - - // Check for the client conneciton - $window.addEventListener('offline', function() { - $scope.$apply(function() { - $scope.clienteOnline = false; - }); - }, true); - - $window.addEventListener('online', function () { - $scope.$apply(function() { - $scope.clienteOnline = true; - }); - }, true); - -}); diff --git a/public/views/includes/connection.html b/public/views/includes/connection.html index 86b63134..55bbea99 100644 --- a/public/views/includes/connection.html +++ b/public/views/includes/connection.html @@ -3,8 +3,8 @@
Error! -

Can't connect to bitcoind.

-

Can't connect to server.

+

Can't connect to bitcoind to get live updates from the p2p network.

+

Can't connect to insight server. Attempting to reconnect...

Can't connect to internet. Please, check your connection.

From 8b88a01f656b7ad30ac1e87c57ad7cfd0a4c82f2 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 13 Feb 2014 17:16:35 -0300 Subject: [PATCH 2/2] add host port to bitcoind error message --- lib/PeerSync.js | 4 +++- public/src/js/controllers/connection.js | 2 ++ public/views/includes/connection.html | 23 ++++++++++++++++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/PeerSync.js b/lib/PeerSync.js index ce1bf1a4..56809394 100644 --- a/lib/PeerSync.js +++ b/lib/PeerSync.js @@ -44,7 +44,9 @@ function spec() { PeerSync.prototype.info = function() { return { - connected: this.connected + connected: this.connected, + host: this.peerdb[0].ipv4, + port: this.peerdb[0].port }; }; diff --git a/public/src/js/controllers/connection.js b/public/src/js/controllers/connection.js index e5dae0bc..4b3cbc33 100644 --- a/public/src/js/controllers/connection.js +++ b/public/src/js/controllers/connection.js @@ -23,6 +23,8 @@ angular.module('insight.connection').controller('ConnectionController', PeerSync.get({}, function(peer) { $scope.apiOnline = peer.connected; + $scope.host = peer.host; + $scope.port = peer.port; }, function() { $scope.apiOnline = false; diff --git a/public/views/includes/connection.html b/public/views/includes/connection.html index 55bbea99..5430475f 100644 --- a/public/views/includes/connection.html +++ b/public/views/includes/connection.html @@ -1,10 +1,23 @@
- -
+
+ Error! -

Can't connect to bitcoind to get live updates from the p2p network.

-

Can't connect to insight server. Attempting to reconnect...

-

Can't connect to internet. Please, check your connection.

+ +

+ Can't connect to bitcoind to get live updates from the p2p network. + (Tried connecting to bitcoind at {{host}}:{{port}} and failed.) +

+ +

+ Can't connect to insight server. Attempting to reconnect... +

+ +

+ Can't connect to internet. Please, check your connection. +

+