Attempt to load transactions from the recent block by default
This commit is contained in:
parent
e83a99ae96
commit
bc8dc2e375
@ -7,12 +7,25 @@ angular.module('flosight.system').controller('IndexController',
|
|||||||
function($scope, Global, getSocket, Blocks) {
|
function($scope, Global, getSocket, Blocks) {
|
||||||
$scope.global = Global;
|
$scope.global = Global;
|
||||||
|
|
||||||
var _getBlocks = function() {
|
var _getBlocks = function(loadTxs) {
|
||||||
Blocks.get({
|
Blocks.get({
|
||||||
limit: BLOCKS_DISPLAYED
|
limit: BLOCKS_DISPLAYED
|
||||||
}, function(res) {
|
}, function(res) {
|
||||||
$scope.blocks = res.blocks;
|
$scope.blocks = res.blocks;
|
||||||
$scope.blocksLength = res.length;
|
$scope.blocksLength = res.length;
|
||||||
|
|
||||||
|
if (loadTxs) {
|
||||||
|
TransactionsByBlock.get({
|
||||||
|
block: res.blocks[0].hash
|
||||||
|
}, function(txs){
|
||||||
|
for (var i = txs.length; i > 0; i--){
|
||||||
|
$scope.txs.unshift(txs[i]);
|
||||||
|
if (parseInt($scope.txs.length, 10) >= parseInt(TRANSACTION_DISPLAYED, 10)) {
|
||||||
|
$scope.txs = $scope.txs.splice(0, TRANSACTION_DISPLAYED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -28,7 +41,7 @@ angular.module('flosight.system').controller('IndexController',
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('block', function() {
|
socket.on('block', function() {
|
||||||
_getBlocks();
|
_getBlocks(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,7 +57,7 @@ angular.module('flosight.system').controller('IndexController',
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.index = function() {
|
$scope.index = function() {
|
||||||
_getBlocks();
|
_getBlocks(true);
|
||||||
_startSocket();
|
_startSocket();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user