From 99edf03c3510ba701db26d6baf4f7c00df3cddc3 Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 5 May 2015 03:12:41 +0300 Subject: [PATCH] changed 'chain' to 'latest' --- lib/node.js | 17 +++++++++++------ package.json | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/node.js b/lib/node.js index 08f68dd..9c3d9fb 100644 --- a/lib/node.js +++ b/lib/node.js @@ -8,6 +8,7 @@ var shelljs = require('shelljs'); var debounce = require('debounce'); var registrar = require('./registrar.js'); var pjson = require('./../package.json'); +var chalk = require('chalk'); var Primus = require('primus'), Emitter = require('primus-emit'), @@ -46,7 +47,7 @@ if(process.env.NODE_ENV === 'production' && INSTANCE_NAME === "") } -function Node() +function Node () { this.info = { name: INSTANCE_NAME || (process.env.EC2_INSTANCE_ID || os.hostname()), @@ -110,7 +111,7 @@ function Node() Node.prototype.startWeb3Connection = function() { - console.info("==> Starting eth connection"); + console.info(chalk.blue('==>'), chalk.bold('Starting eth connection')); web3.setProvider( new web3.providers.HttpProvider('http://' + (process.env.RPC_HOST || 'localhost') + ':' + (process.env.RPC_PORT || '8080')) ); @@ -128,8 +129,8 @@ Node.prototype.checkWeb3Connection = function() if( !_.isUndefined(tmp) ) { - console.log('eth ', tmp); - console.info("==> Ethereum connection established"); + console.log('eth', tmp); + console.info('==>', 'Ethereum connection established'); this._web3 = true; this.init(); @@ -139,7 +140,7 @@ Node.prototype.checkWeb3Connection = function() } catch(err) { - console.error('xx> Ethereum connection attempt #' + this._called++ + ' failed;'); + console.error('xx>', 'Ethereum connection attempt #' + this._called++ + ' failed;'); process.nextTick( function() { @@ -516,6 +517,8 @@ Node.prototype.getHistory = function (range) var history = []; var interv = {}; + console.time('=== Got history in'); + if( _.isUndefined(range) || range === null) { interv = { @@ -542,6 +545,8 @@ Node.prototype.getHistory = function (range) } } + console.timeEnd('=== Got history in'); + return history.reverse(); } @@ -591,7 +596,7 @@ Node.prototype.setWatches = function() var self = this; try { - this.chainFilter = web3.eth.filter('chain'); + this.chainFilter = web3.eth.filter('latest'); this.chainFilter.watch( function (log) { var now = _.now(); diff --git a/package.json b/package.json index 9d630b2..e2772ad 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ }, "dependencies": { "async": "^0.9.0", + "chalk": "^1.0.0", "debounce": "1.0.0", "debug": "2.1.3", "lodash": "3.7.0",