diff --git a/app.js b/app.js index d3ed687..f4eb12d 100644 --- a/app.js +++ b/app.js @@ -43,7 +43,7 @@ api.on('connection', function(spark) { spark.on('hello', function(data) { console.log('Latency: ', spark.latency); - console.log('got hello data from ', spark.id); + console.log('Got hello data from ', spark.id); console.log(data); if(typeof data.secret === 'undefined' || data.secret !== WS_SECRET) @@ -75,7 +75,7 @@ api.on('connection', function(spark) { spark.on('update', function(data) { console.log('Latency: ', spark.latency); - console.log('got update from ' + spark.id); + console.log('Got update from ' + spark.id); if(typeof data.id !== 'undefined' && typeof data.stats !== 'undefined') { @@ -101,9 +101,6 @@ api.on('connection', function(spark) { spark.on('latency', function(data) { - console.log('Latency: ', data.latency); - console.log('got ping from ' + spark.id); - if(typeof data.id !== 'undefined') { var stats = Nodes.updateLatency(data.id, data.latency); @@ -126,9 +123,6 @@ client.on('connection', function(spark) { console.log(spark.query); spark.on('ready', function(data){ - console.log('got hello data from ' + spark.id); - console.log(data); - spark.emit('init', {nodes: Nodes.all()}); var blockPropagationChart = Nodes.blockPropagationChart(); diff --git a/models/history.js b/models/history.js index 4b052f6..38ae779 100644 --- a/models/history.js +++ b/models/history.js @@ -70,7 +70,6 @@ History.prototype.add = function(block, id) } item.propagTimes.push({node: id, received: now, propagation: block.propagation}); - console.log('item: ', item); this._save(item); } this.getNodePropagation(id); @@ -187,6 +186,30 @@ History.prototype.getUncleCount = function(id) return uncleBins; } +History.prototype.getTransactionsCount = function(id) +{ + var uncles = _(this._items) + .sortByOrder('height', false) + .slice(0, MAX_BINS - 1) + .reverse() + .map(function(item) + { + return item.block.transactions.length; + }) + .value(); + + var uncleBins = _.fill(Array(MAX_BINS), 0); + + var sumMapper = function(array, key) { + uncleBins[key] = _.sum(array); + return _.sum(array); + }; + + _.map(_.chunk(uncles, MAX_UNCLES_PER_BIN), sumMapper); + + return uncleBins; +} + History.prototype.history = function() { return _.chain(this._items).sortBy('number').reverse().value();