fixed callback already called bug

This commit is contained in:
cubedro 2015-05-19 03:40:41 +03:00
parent 752304a422
commit c298049ebc

View File

@ -411,17 +411,18 @@ Node.prototype.getStats = function(forced)
peers: function (callback) peers: function (callback)
{ {
async.nextTick(function () { async.nextTick(function () {
var peers; var peers = null;
var error = null;
try { try {
peers = web3.toDecimal(web3.net.peerCount); peers = web3.toDecimal(web3.net.peerCount);
} }
catch (err) { catch (err) {
console.error('xx>', 'PeerCount failed: ', err); console.error('xx>', 'PeerCount failed: ', err);
callback(err, null); error = err;
} }
callback(null, peers); callback(error, peers);
}); });
}, },
pending: function (callback) pending: function (callback)
@ -439,34 +440,36 @@ Node.prototype.getStats = function(forced)
mining: function (callback) mining: function (callback)
{ {
async.nextTick(function () { async.nextTick(function () {
var mining; var mining = null;
var error = null;
try { try {
mining = web3.eth.mining; mining = web3.eth.mining;
} }
catch (err) { catch (err) {
console.error('xx>', 'Mining failed: ', err); console.error('xx>', 'Mining failed: ', err);
callback(err, null); error = err;
} }
callback(null, mining); callback(error, mining);
}); });
}, },
hashrate: function (callback) hashrate: function (callback)
{ {
if(self.stats.mining) { if(self.stats.mining) {
async.nextTick(function () { async.nextTick(function () {
var hashrate; var hashrate = null;
var error = null;
try { try {
hashrate = web3.eth.hashrate; hashrate = web3.eth.hashrate;
} }
catch (err) { catch (err) {
console.error('xx>', 'Hashrate failed: ', err); console.error('xx>', 'Hashrate failed: ', err);
callback(err, null); error = err;
} }
callback(null, hashrate); callback(error, hashrate);
}); });
} }
else { else {
@ -476,33 +479,35 @@ Node.prototype.getStats = function(forced)
gasPrice: function (callback) gasPrice: function (callback)
{ {
async.nextTick(function () { async.nextTick(function () {
var gasPrice; var gasPrice = null;
var error = null;
try { try {
gasPrice = web3.toBigNumber(web3.eth.gasPrice).toString(10); gasPrice = web3.toBigNumber(web3.eth.gasPrice).toString(10);
} }
catch (err) { catch (err) {
console.error('xx>', 'gasPrice failed: ', err); console.error('xx>', 'gasPrice failed: ', err);
callback(err, null); error = err;
} }
callback(null, gasPrice); callback(error, gasPrice);
}); });
}, },
// minerName: function (callback) // minerName: function (callback)
// { // {
// async.nextTick(function () { // async.nextTick(function () {
// var minerName; // var minerName = null;
// var error = null;
// try { // try {
// minerName = self.getMinerName(self.stats.block.miner); // minerName = self.getMinerName(self.stats.block.miner);
// } // }
// catch (err) { // catch (err) {
// console.error('xx>', 'minerName failed: ', err); // console.error('xx>', 'minerName failed: ', err);
// callback(err, null); // error = err;
// } // }
// callback(null, minerName); // callback(error, minerName);
// }); // });
// } // }
}, },