diff --git a/lib/explorer.js b/lib/explorer.js index d002639..3cb9e34 100644 --- a/lib/explorer.js +++ b/lib/explorer.js @@ -21,7 +21,7 @@ function coinbase_supply(cb) { } function rpcCommand(params, cb) { - client.cmd([{method: params[0].method, params: params[0].parameters}], function(err, response){ + client.cmd([{method: params[0].method, params: params[0].parameters}], function(err, response) { if (err) return cb('There was an error. Check your console.'); else @@ -41,7 +41,7 @@ module.exports = { if (settings.index.show_hashrate == false) return cb('-'); if (settings.use_rpc) { if (settings.nethash == 'netmhashps') { - rpcCommand([{method:'getmininginfo', parameters: []}], function(response){ + rpcCommand([{method:'getmininginfo', parameters: []}], function(response) { if (response == 'There was an error. Check your console.') { return cb(response);} if (response.netmhashps) { if (settings.nethash_units == 'K') { @@ -62,7 +62,7 @@ module.exports = { } }); } else { - rpcCommand([{method:'getnetworkhashps', parameters: []}], function(response){ + rpcCommand([{method:'getnetworkhashps', parameters: []}], function(response) { if (response == 'There was an error. Check your console.') { return cb(response);} if (response) { if (settings.nethash_units == 'K') { @@ -132,7 +132,7 @@ module.exports = { get_difficulty: function(cb) { if (settings.use_rpc) { - rpcCommand([{method:'getdifficulty', parameters: []}], function(response){ + rpcCommand([{method:'getdifficulty', parameters: []}], function(response) { return cb(response); }); } else { @@ -145,7 +145,7 @@ module.exports = { get_connectioncount: function(cb) { if (settings.use_rpc) { - rpcCommand([{method:'getconnectioncount', parameters: []}], function(response){ + rpcCommand([{method:'getconnectioncount', parameters: []}], function(response) { return cb(response); }); } else { @@ -169,7 +169,7 @@ module.exports = { else params.push(split[i]); } - rpcCommand([{method:method_name, parameters: params}], function(response){ + rpcCommand([{method:method_name, parameters: params}], function(response) { return cb(response); }); } else { @@ -184,7 +184,7 @@ module.exports = { get_blockcount: function(cb) { if (settings.use_rpc) { - rpcCommand([{method:'getblockcount', parameters: []}], function(response){ + rpcCommand([{method:'getblockcount', parameters: []}], function(response) { return cb(response); }); } else { @@ -197,7 +197,7 @@ module.exports = { get_blockhash: function(height, cb) { if (settings.use_rpc) { - rpcCommand([{method:'getblockhash', parameters: [parseInt(height)]}], function(response){ + rpcCommand([{method:'getblockhash', parameters: [parseInt(height)]}], function(response) { return cb(response); }); } else { @@ -210,7 +210,7 @@ module.exports = { get_block: function(hash, cb) { if (settings.use_rpc) { - rpcCommand([{method:'getblock', parameters: [hash]}], function(response){ + rpcCommand([{method:'getblock', parameters: [hash]}], function(response) { return cb(response); }); } else { @@ -223,7 +223,7 @@ module.exports = { get_rawtransaction: function(hash, cb) { if (settings.use_rpc) { - rpcCommand([{method:'getrawtransaction', parameters: [hash, 1]}], function(response){ + rpcCommand([{method:'getrawtransaction', parameters: [hash, 1]}], function(response) { return cb(response); }); } else { @@ -236,7 +236,7 @@ module.exports = { get_maxmoney: function(cb) { if (settings.use_rpc) { - rpcCommand([{method:'getmaxmoney', parameters: []}], function(response){ + rpcCommand([{method:'getmaxmoney', parameters: []}], function(response) { return cb(response); }); } else { @@ -249,7 +249,7 @@ module.exports = { get_maxvote: function(cb) { if (settings.use_rpc) { - rpcCommand([{method:'getmaxvote', parameters: []}], function(response){ + rpcCommand([{method:'getmaxvote', parameters: []}], function(response) { return cb(response); }); } else { @@ -262,11 +262,8 @@ module.exports = { get_vote: function(cb) { if (settings.use_rpc) { - client.cmd([{method:'getvote', params: []}], function(err, response){ - if (err) - return cb('There was an error. Check your console.'); - else - return cb(response); + rpcCommand([{method:'getvote', params: []}], function(response) { + return cb(response); }); } else { var uri = base_url + 'getvote'; @@ -278,11 +275,8 @@ module.exports = { get_phase: function(cb) { if (settings.use_rpc) { - client.cmd([{method:'getphase', params: []}], function(err, response){ - if (err) - return cb('There was an error. Check your console.'); - else - return cb(response); + rpcCommand([{method:'getphase', params: []}], function(response) { + return cb(response); }); } else { var uri = base_url + 'getphase'; @@ -294,11 +288,8 @@ module.exports = { get_reward: function(cb) { if (settings.use_rpc) { - client.cmd([{method:'getreward', params: []}], function(err, response){ - if (err) - return cb('There was an error. Check your console.'); - else - return cb(response); + rpcCommand([{method:'getreward', params: []}], function(response) { + return cb(response); }); } else { var uri = base_url + 'getreward'; @@ -310,11 +301,8 @@ module.exports = { get_estnext: function(cb) { if (settings.use_rpc) { - client.cmd([{method:'getnextrewardestimate', params: []}], function(err, response){ - if (err) - return cb('There was an error. Check your console.'); - else - return cb(response); + rpcCommand([{method:'getnextrewardestimate', params: []}], function(response) { + return cb(response); }); } else { var uri = base_url + 'getnextrewardestimate'; @@ -326,11 +314,8 @@ module.exports = { get_nextin: function(cb) { if (settings.use_rpc) { - client.cmd([{method:'getnextrewardwhenstr', params: []}], function(err, response){ - if (err) - return cb('There was an error. Check your console.'); - else - return cb(response); + rpcCommand([{method:'getnextrewardwhenstr', params: []}], function(response) { + return cb(response); }); } else { var uri = base_url + 'getnextrewardwhenstr'; @@ -398,29 +383,20 @@ module.exports = { get_supply: function(cb) { if (settings.use_rpc) { if ( settings.supply == 'HEAVY' ) { - client.cmd([{method:'getsupply', params: []}], function(err, response){ - if (err) - return cb('There was an error. Check your console.'); - else - return cb(response); + rpcCommand([{method:'getsupply', params: []}], function(response) { + return cb(response); }); } else if (settings.supply == 'GETINFO') { - client.cmd([{method:'getinfo', params: []}], function(err, response){ - if (err) - return cb('There was an error. Check your console.'); - else - return cb(response.moneysupply); + rpcCommand([{method:'getinfo', params: []}], function(response) { + return cb(response.moneysupply); }); } else if (settings.supply == 'BALANCES') { module.exports.balance_supply(function(supply) { return cb(supply/100000000); }); } else if (settings.supply == 'TXOUTSET') { - client.cmd([{method:'gettxoutsetinfo', params: []}], function(err, response){ - if (err) - return cb('There was an error. Check your console.'); - else - return cb(response.total_amount); + rpcCommand([{method:'gettxoutsetinfo', params: []}], function(response) { + return cb(response.total_amount); }); } else { coinbase_supply(function(supply) {