when arrive tx, push on list. fixed streamed blocks on homepage.

This commit is contained in:
Gustavo Cortez 2014-02-09 21:11:20 -03:00
parent 34f2e933b6
commit db8b6e2728
5 changed files with 22 additions and 13 deletions

View File

@ -109,6 +109,9 @@ exports.list = function(req, res) {
else {
var blockshashList = [];
var limit = parseInt(req.query.limit || blocks.length);
if (blocks.length < limit) {
limit = blocks.length;
}
for(var i=0;i<limit;i++) {
blockshashList.push(blocks[i].hash);
}

View File

@ -74,7 +74,7 @@ if (!config.disableHistoricSync) {
historicSync.smartImport({}, function(err){
var txt = 'ended.';
if (err) txt = 'ABORTED with error: ' + err.message;
else
else
ps.allowReorgs = true;
console.log('[historic_sync] ' + txt, historicSync.info());

View File

@ -7,8 +7,8 @@ function spec(b) {
var RpcClient = require('bitcore/RpcClient').class(),
// networks = require('bitcore/network'),
BitcoreTransaction = require('bitcore/Transaction').class(),
BitcoreBlock = require('bitcore/Block').class(),
util = require('bitcore/util/util'),
// BitcoreBlock = require('bitcore/Block').class(),
// util = require('bitcore/util/util'),
config = require('../config/config');
var rpc = b.rpc || new RpcClient(config.bitcoind);

View File

@ -33,7 +33,7 @@ angular.module('insight.system').controller('HeaderController',
};
socket.on('block', function(block) {
var blockHash = block.hash.hash.toString();
var blockHash = block.hash.toString();
console.log('Updated Blocks Height!');
_getBlock(blockHash);
});

View File

@ -4,7 +4,7 @@ var TRANSACTION_DISPLAYED = 5;
var BLOCKS_DISPLAYED = 5;
angular.module('insight.system').controller('IndexController',
function($scope, $rootScope, Global, getSocket, Blocks, Transactions) {
function($scope, $rootScope, Global, getSocket, Blocks, Transaction) {
$scope.global = Global;
var _getBlocks = function() {
@ -15,12 +15,12 @@ angular.module('insight.system').controller('IndexController',
$scope.blocksLength = res.lenght;
});
};
var _getTransactions = function() {
Transactions.get({
limit: TRANSACTION_DISPLAYED
var _getTransaction = function(txid, cb) {
Transaction.get({
txId: txid
}, function(res) {
$scope.txs = res.txs;
cb(res);
});
};
@ -32,11 +32,18 @@ angular.module('insight.system').controller('IndexController',
socket.on('tx', function(tx) {
console.log('Transaction received! ' + JSON.stringify(tx));
_getTransactions();
var txStr = tx.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) {
var blockHash = block.hash.hash.toString();
var blockHash = block.hash.toString();
console.log('Block received! ' + JSON.stringify(blockHash));
_getBlocks();
});
@ -48,7 +55,6 @@ angular.module('insight.system').controller('IndexController',
$scope.index = function() {
_getBlocks();
_getTransactions();
};
$scope.txs = [];