limit live transactions in the homepage

This commit is contained in:
Mario Colque 2014-01-29 11:25:27 -03:00
parent 4d69c974c4
commit f2963a2b6d

View File

@ -7,11 +7,11 @@ angular.module('insight.system').controller('IndexController',
function($scope, $rootScope, Global, getSocket, Blocks, Block, Transactions, Transaction) { function($scope, $rootScope, Global, getSocket, Blocks, Block, Transactions, Transaction) {
$scope.global = Global; $scope.global = Global;
var _getTransaction = function(txid) { var _getTransaction = function(txid, cb) {
Transaction.get({ Transaction.get({
txId: txid txId: txid
}, function(res) { }, function(res) {
$scope.txs.unshift(res); cb(res);
}); });
}; };
@ -30,14 +30,15 @@ angular.module('insight.system').controller('IndexController',
$scope.flashMessage = $rootScope.flashMessage || null; $scope.flashMessage = $rootScope.flashMessage || null;
socket.on('tx', function(tx) { socket.on('tx', function(tx) {
var txStr = tx.txid.toString();
_getTransaction(txStr);
console.log('Transaction received! ' + JSON.stringify(tx)); console.log('Transaction received! ' + JSON.stringify(tx));
if (parseInt($scope.txs.length, 10) >= parseInt(TRANSACTION_DISPLAYED, 10)) {
$scope.txs = $scope.txs.splice(0, TRANSACTION_DISPLAYED); var txStr = tx.txid.toString();
} _getTransaction(txStr, function(res) {
$scope.txs.unshift(res);
if (parseInt($scope.txs.length, 10) >= parseInt(TRANSACTION_DISPLAYED, 10)) {
$scope.txs = $scope.txs.splice(0, TRANSACTION_DISPLAYED);
}
});
}); });
socket.on('block', function(block) { socket.on('block', function(block) {