when arrive tx, push on list. fixed streamed blocks on homepage.
This commit is contained in:
parent
34f2e933b6
commit
db8b6e2728
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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() {
|
||||
|
@ -16,11 +16,11 @@ angular.module('insight.system').controller('IndexController',
|
|||
});
|
||||
};
|
||||
|
||||
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 = [];
|
||||
|
|
Loading…
Reference in New Issue