commit
763950c2d2
6
app.js
6
app.js
@ -3,13 +3,13 @@ var nodeModel = require('./lib/node');
|
||||
var node = new nodeModel();
|
||||
|
||||
var gracefulShutdown = function() {
|
||||
console.log("Received kill signal, shutting down gracefully.");
|
||||
console.warn("Received kill signal, shutting down gracefully.");
|
||||
|
||||
node.stop();
|
||||
console.log("Closed node watcher");
|
||||
console.info("Closed node watcher");
|
||||
|
||||
setTimeout(function(){
|
||||
console.log("Closed out remaining connections.");
|
||||
console.info("Closed out remaining connections.");
|
||||
process.exit(0)
|
||||
}, 2*1000);
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ if [ -f /usr/bin/ethereum ]
|
||||
then
|
||||
ethereum -rpc true
|
||||
else
|
||||
eth -x 15 -l 30303 -r poc-8.ethdev.com -p 30303 -m off -j
|
||||
eth -x 15 -l 30303 -r poc-8.ethdev.com -p 30303 -m off -v 1 -j
|
||||
fi
|
43
lib/node.js
43
lib/node.js
@ -13,7 +13,7 @@ var ETH_VERSION,
|
||||
API_VERSION;
|
||||
var INSTANCE_NAME = process.env.INSTANCE_NAME;
|
||||
|
||||
web3.setProvider(new web3.providers.HttpProvider('http://' + (process.env.RPC_HOST || 'localhost') + ':' + (process.env.RPC_PORT || '8080')));
|
||||
web3.setProvider(new web3.providers.HttpProvider('http://' + (process.env.RPC_HOST || 'localhost') + ':' + (process.env.RPC_PORT || '8545')));
|
||||
|
||||
Socket = Primus.createSocket({
|
||||
transformer: 'websockets',
|
||||
@ -42,7 +42,7 @@ function Node()
|
||||
API_VERSION = web3.version.api;
|
||||
}
|
||||
catch (err) {
|
||||
console.log("couldn't get Version");
|
||||
console.error("couldn't get Version");
|
||||
}
|
||||
|
||||
this.info = {
|
||||
@ -88,16 +88,21 @@ function Node()
|
||||
|
||||
socket.on('open', function open() {
|
||||
socket.emit('hello', { id: self.id, info: self.info, secret: WS_SECRET });
|
||||
console.log('The connection has been opened.');
|
||||
console.log('Trying to login');
|
||||
}).on('end', function end() {
|
||||
console.info('The connection has been opened.');
|
||||
console.info('Trying to login');
|
||||
})
|
||||
.on('end', function end() {
|
||||
self._socket = false;
|
||||
}).on('error', function error(err) {
|
||||
console.log(err);
|
||||
}).on('reconnecting', function reconnecting(opts) {
|
||||
console.log('We are scheduling a reconnect operation', opts);
|
||||
}).on('data', function incoming(data) {
|
||||
console.log('Received some data', data);
|
||||
console.error('Socket connection closed');
|
||||
})
|
||||
.on('error', function error(err) {
|
||||
console.error(err);
|
||||
})
|
||||
.on('reconnecting', function reconnecting(opts) {
|
||||
console.warn('We are scheduling a reconnect operation', opts);
|
||||
})
|
||||
.on('data', function incoming(data) {
|
||||
console.info('Received some data', data);
|
||||
});
|
||||
|
||||
socket.on('ready', function()
|
||||
@ -105,7 +110,7 @@ function Node()
|
||||
self._socket = true;
|
||||
self.sendUpdate(true);
|
||||
|
||||
console.log('The connection has been established.');
|
||||
console.info('The connection has been established.');
|
||||
});
|
||||
|
||||
this.init();
|
||||
@ -134,7 +139,7 @@ Node.prototype.isActive = function()
|
||||
code: '1',
|
||||
msg: err
|
||||
});
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
this.stats.active = false;
|
||||
@ -158,7 +163,7 @@ Node.prototype.getBlock = function(number)
|
||||
|
||||
if(typeof number === 'undefined'){
|
||||
try {
|
||||
number = parseInt(web3.eth.blockNumber);
|
||||
number = web3.eth.blockNumber;
|
||||
|
||||
if(number === this.stats.block.number + 1)
|
||||
return this.stats.block;
|
||||
@ -168,7 +173,7 @@ Node.prototype.getBlock = function(number)
|
||||
code: '3',
|
||||
msg: err
|
||||
});
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +192,7 @@ Node.prototype.getBlock = function(number)
|
||||
code: '2',
|
||||
msg: err
|
||||
});
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
return block;
|
||||
@ -340,7 +345,7 @@ Node.prototype.setWatches = function()
|
||||
|
||||
// this.pendingWatch = web3.eth.filter('pending');
|
||||
// this.pendingWatch.watch( function(log) {
|
||||
// console.log(log);
|
||||
// console.log(log);
|
||||
// // console.log(self.pendingWatch.get());
|
||||
// // console.log('pending changed');
|
||||
// // self.stats.pending = parseInt(log.number);
|
||||
@ -354,7 +359,7 @@ Node.prototype.setWatches = function()
|
||||
|
||||
this.updateInterval = setInterval(function(){
|
||||
self.update();
|
||||
}, 1000);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
Node.prototype.emit = function(message, payload)
|
||||
@ -364,7 +369,7 @@ Node.prototype.emit = function(message, payload)
|
||||
socket.emit(message, payload);
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user