bug fixes
This commit is contained in:
parent
491b2aa6f0
commit
df58525fd4
36
lib/node.js
36
lib/node.js
@ -8,6 +8,13 @@ var Primus = require('primus'),
|
|||||||
Latency = require('primus-spark-latency'),
|
Latency = require('primus-spark-latency'),
|
||||||
Socket;
|
Socket;
|
||||||
|
|
||||||
|
var ETH_VERSION,
|
||||||
|
NET_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')));
|
||||||
|
|
||||||
Socket = Primus.createSocket({
|
Socket = Primus.createSocket({
|
||||||
transformer: 'websockets',
|
transformer: 'websockets',
|
||||||
pathname: '/api',
|
pathname: '/api',
|
||||||
@ -15,15 +22,9 @@ Socket = Primus.createSocket({
|
|||||||
plugin: {emitter: Emitter, sparkLatency: Latency}
|
plugin: {emitter: Emitter, sparkLatency: Latency}
|
||||||
});
|
});
|
||||||
|
|
||||||
var INSTANCE_NAME = process.env.INSTANCE_NAME;
|
if(process.env.NODE_ENV === 'production' && INSTANCE_NAME === "")
|
||||||
|
|
||||||
if(process.env.NODE_ENV === 'production')
|
|
||||||
{
|
{
|
||||||
if(process.env.INSTANCE_NAME === "")
|
INSTANCE_NAME = shelljs.exec('ec2metadata --instance-id', {silent: true}).output;
|
||||||
{
|
|
||||||
INSTANCE_NAME = shelljs.exec('ec2metadata --instance-id', {silent: true}).output;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var socket = new Socket(process.env.WS_SERVER || 'ws://localhost:3000');
|
var socket = new Socket(process.env.WS_SERVER || 'ws://localhost:3000');
|
||||||
@ -35,8 +36,6 @@ function Node()
|
|||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
web3.setProvider(new web3.providers.HttpProvider('http://' + (process.env.RPC_HOST || 'localhost') + ':' + (process.env.RPC_PORT || '8080')));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ETH_VERSION = web3.version.client;
|
ETH_VERSION = web3.version.client;
|
||||||
NET_VERSION = web3.version.network;
|
NET_VERSION = web3.version.network;
|
||||||
@ -174,24 +173,13 @@ Node.prototype.getBlock = function(number)
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
block = web3.eth.getBlock(number);
|
block = web3.eth.getBlock(number, true);
|
||||||
block.arrival = Date.now();
|
block.arrival = Date.now();
|
||||||
block.propagation = block.arrival - (block.timestamp * 1000);
|
block.propagation = block.arrival - (block.timestamp * 1000);
|
||||||
|
|
||||||
if(block.hash != '?' && typeof block.difficulty !== 'undefined')
|
if(block.hash != '?' && typeof block.difficulty !== 'undefined')
|
||||||
{
|
{
|
||||||
block.difficulty = web3.toDecimal(block.difficulty);
|
block.difficulty = web3.toDecimal(block.difficulty);
|
||||||
|
|
||||||
try {
|
|
||||||
block.txCount = web3.eth.getBlockTransactionCount(block.hash) || '?';
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
this.stats.errors.push({
|
|
||||||
code: '4',
|
|
||||||
msg: err
|
|
||||||
});
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@ -279,7 +267,7 @@ Node.prototype.txDensityChart = function()
|
|||||||
{
|
{
|
||||||
return txDensity = _.map(this.blocks, function(block)
|
return txDensity = _.map(this.blocks, function(block)
|
||||||
{
|
{
|
||||||
return block.txCount;
|
return block.transactions.length;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +341,7 @@ Node.prototype.setWatches = function()
|
|||||||
this.pendingWatch = web3.eth.filter('pending');
|
this.pendingWatch = web3.eth.filter('pending');
|
||||||
this.pendingWatch.watch( function(log) {
|
this.pendingWatch.watch( function(log) {
|
||||||
console.log(log);
|
console.log(log);
|
||||||
console.log(self.pendingWatch.get());
|
// console.log(self.pendingWatch.get());
|
||||||
// console.log('pending changed');
|
// console.log('pending changed');
|
||||||
// self.stats.pending = parseInt(log.number);
|
// self.stats.pending = parseInt(log.number);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user