optimization
This commit is contained in:
parent
019507a44f
commit
c2f8a103bd
40
lib/node.js
40
lib/node.js
@ -177,9 +177,10 @@ Node.prototype.setupSockets = function()
|
||||
.on('ready', function()
|
||||
{
|
||||
self._socket = true;
|
||||
self.sendUpdate(true);
|
||||
|
||||
console.info('==> The connection has been established.');
|
||||
|
||||
self.updateBlock();
|
||||
self.update(true);
|
||||
})
|
||||
.on('data', function incoming(data)
|
||||
{
|
||||
@ -216,7 +217,7 @@ Node.prototype.setupSockets = function()
|
||||
})
|
||||
.on('reconnecting', function reconnecting(opts)
|
||||
{
|
||||
console.warn('We are scheduling a reconnect operation', opts);
|
||||
console.warn('!!!', 'We are scheduling a reconnect operation', opts);
|
||||
});
|
||||
}
|
||||
|
||||
@ -249,6 +250,10 @@ Node.prototype.setInactive = function()
|
||||
|
||||
Node.prototype.getInfo = function()
|
||||
{
|
||||
var start = _.now();
|
||||
|
||||
console.info('==>', 'Getting info');
|
||||
|
||||
try {
|
||||
this.info.coinbase = web3.eth.coinbase;
|
||||
this.info.node = web3.version.client;
|
||||
@ -256,7 +261,8 @@ Node.prototype.getInfo = function()
|
||||
this.info.protocol = web3.toDecimal(web3.version.ethereum);
|
||||
this.info.api = web3.version.api;
|
||||
|
||||
console.info(this.info);
|
||||
console.info('==>', 'Got info in', _.now() - start, 'ms');
|
||||
console.info(' i ', this.info);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -273,7 +279,8 @@ Node.prototype.getBlock = function(number)
|
||||
number: 0,
|
||||
hash: '?',
|
||||
difficulty: 0,
|
||||
timestamp: 0
|
||||
timestamp: 0,
|
||||
miner: ''
|
||||
};
|
||||
|
||||
if( _.isUndefined(number) )
|
||||
@ -617,8 +624,9 @@ Node.prototype.setWatches = function()
|
||||
{
|
||||
var now = _.now();
|
||||
var time = now - self._lastPendingLog;
|
||||
self._lastPendingLog = now;
|
||||
|
||||
console.log('>>> Pending Filter triggered: ', now);
|
||||
console.log('>>> Pending Filter triggered: ', now, '- last trigger:', time);
|
||||
|
||||
if(time > 50)
|
||||
{
|
||||
@ -630,8 +638,6 @@ Node.prototype.setWatches = function()
|
||||
self.update(true);
|
||||
}, 50);
|
||||
}
|
||||
|
||||
self._lastPendingLog = now;
|
||||
});
|
||||
}
|
||||
catch (err)
|
||||
@ -651,13 +657,17 @@ Node.prototype.setWatches = function()
|
||||
|
||||
Node.prototype.installContract = function()
|
||||
{
|
||||
var start = _.now();
|
||||
|
||||
try {
|
||||
Contract = web3.eth.contract( registrar.desc );
|
||||
this._Registrar = new Contract( registrar.address );
|
||||
|
||||
console.log('==>', 'Installed Registrar contract in', _.now() - start, 'ms');
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
console.error("Couldn't set up registrar contract");
|
||||
console.error("!!!", "Couldn't set up registrar contract");
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
@ -667,20 +677,14 @@ Node.prototype.init = function()
|
||||
// Fetch node info
|
||||
this.getInfo();
|
||||
|
||||
// Start socket connection
|
||||
this.startSocketConnection();
|
||||
|
||||
// Install Registrar contract
|
||||
this.installContract();
|
||||
|
||||
// Start socket connection
|
||||
this.startSocketConnection();
|
||||
|
||||
// Set filters
|
||||
this.setWatches();
|
||||
|
||||
// Update block and send info
|
||||
this.updateBlock();
|
||||
|
||||
// Update stats and send info
|
||||
this.update();
|
||||
}
|
||||
|
||||
Node.prototype.stop = function()
|
||||
|
Loading…
Reference in New Issue
Block a user