Skip to content

Commit

Permalink
impr(search): use network as param for testing blockHash
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Werner committed Nov 4, 2019
1 parent 8af7acf commit 659029c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
15 changes: 7 additions & 8 deletions public/src/js/controllers/search.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';
// var isValidBlockHash = require('../utils/isValidBlockHash');
// var isValidAddress = require('../utils/isValidAddress');
// var isValidTransactionHash = require('../utils/isValidTransactionHash');

angular.module('insight.search')
.controller('SearchController',
function ($scope, $routeParams, $location, $timeout, Global, Block, Transaction, Address, BlockHashValidator, TransactionHashValidator, AddressValidator, BlockByHeight) {
function ($scope, $rootScope, $routeParams, $location, $timeout, Global, Block, Transaction, Address, BlockHashValidator, TransactionHashValidator, AddressValidator, BlockByHeight) {
$scope.global = Global;
$scope.loading = false;

var currentNetwork = $rootScope.network;

var _badQuery = function () {
$scope.badQuery = true;

Expand All @@ -25,9 +25,8 @@ angular.module('insight.search')
var q = $scope.q;
$scope.badQuery = false;
$scope.loading = true;

var isBlockHeight = isFinite(q);
var isBlockHash = BlockHashValidator.test(q);
var isBlockHash = BlockHashValidator.test(q, currentNetwork);
var isTransactionHash = TransactionHashValidator.test(q);
var isAddress = AddressValidator.test(q);

Expand All @@ -52,15 +51,15 @@ angular.module('insight.search')
_resetSearch();
$location.path('/block/' + hash.blockHash);
}, badQueryLoadHandler);
}
};
var fetchAndRedirectAddressSearch = function () {
return Address.get({
addrStr: q
}, function () {
_resetSearch();
$location.path('address/' + q);
}, badQueryLoadHandler);
}
};
var fetchAndRedirectBlockSearch = function () {
// Block hashes are identified by expecting 10 trailing zeroes as prefix (see difficulty)
// If we are in the 1/Inf case of a txhash starting with ten zeroes, we will fallback on tx
Expand Down
5 changes: 3 additions & 2 deletions public/src/js/controllers/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ angular.module('insight.status').controller('StatusController',
$scope.sync = sync;
};

var socket = getSocket($scope);

var _startSocket = function () {
socket.emit('subscribe', 'sync');
socket.on('status', function(sync) {
_onSyncUpdate(sync);
});
};

var socket = getSocket($scope);

socket.on('connect', function() {
_startSocket();
});
Expand Down
11 changes: 6 additions & 5 deletions public/src/js/controllers/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ function($scope, $rootScope, $routeParams, $location, Global, Transaction, Trans
Transaction.get({
txId: txid
}, function(tx) {
$rootScope.titleDetail = tx.txid.substring(0,7) + '...';
$rootScope.titleDetail = tx.txid.substring(0,7) + '...';
$rootScope.flashMessage = null;
$scope.tx = tx;
_processTX(tx);
$scope.txs.unshift(tx);
$scope.tx = tx;
_processTX(tx);
$scope.txs.unshift(tx);
}, function(e) {
// FIXME : Do we even enter here ? status 4** do not throw exceptions
if (e.status === 400) {
$rootScope.flashMessage = 'Invalid Transaction ID: ' + $routeParams.txId;
}
Expand Down Expand Up @@ -164,7 +165,7 @@ function($scope, $rootScope, $routeParams, $location, Global, Transaction, Trans
$scope.v_index = parseInt($routeParams.v_index);
$scope.itemsExpanded = true;
}

//Init without txs
$scope.txs = [];

Expand Down

0 comments on commit 659029c

Please sign in to comment.