mirror of https://github.com/BTCPrivate/z-nomp.git
added support for difficulty and blockreward
This commit is contained in:
parent
550b09767e
commit
93274f907b
|
@ -1,6 +1,7 @@
|
|||
var async = require('async');
|
||||
|
||||
var Poloniex = require('./apiPoloniex.js');
|
||||
var Stratum = require('stratum-pool');
|
||||
|
||||
module.exports = function(logger){
|
||||
|
||||
|
@ -29,9 +30,6 @@ module.exports = function(logger){
|
|||
symbol: poolConfig.coin.symbol,
|
||||
difficulty: 0,
|
||||
reward: 0,
|
||||
avgPrice: { BTC: 0, LTC: 0 },
|
||||
avgDepth: { BTC: 0, LTC: 0 },
|
||||
avgVolume: { BTC: 0, LTC: 0 },
|
||||
prices: {},
|
||||
depths: {},
|
||||
volumes: {},
|
||||
|
@ -158,7 +156,7 @@ module.exports = function(logger){
|
|||
}
|
||||
async.parallel(depthTasks, function(err){
|
||||
if (err){
|
||||
logger.error(logSystem, 'Check', 'Error while checking profitability: ' + err);
|
||||
taskCallback(err);
|
||||
return;
|
||||
}
|
||||
taskCallback();
|
||||
|
@ -207,13 +205,67 @@ module.exports = function(logger){
|
|||
callback(null);
|
||||
};
|
||||
|
||||
this.getCoindDaemonInfo = function(callback){
|
||||
var daemonTasks = [];
|
||||
Object.keys(profitStatus).forEach(function(algo){
|
||||
Object.keys(profitStatus[algo]).forEach(function(symbol){
|
||||
var coinName = profitStatus[algo][symbol].name;
|
||||
var poolConfig = poolConfigs[coinName];
|
||||
var daemonConfig = poolConfig.shareProcessing.internal.daemon;
|
||||
daemonTasks.push(function(callback){
|
||||
_this.getDaemonInfoForCoin(symbol, daemonConfig, callback)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (daemonTasks.length == 0){
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
async.parallel(daemonTasks, function(err){
|
||||
if (err){
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
callback(null);
|
||||
});
|
||||
};
|
||||
this.getDaemonInfoForCoin = function(symbol, cfg, callback){
|
||||
var daemon = new Stratum.daemon.interface([cfg]);
|
||||
daemon.once('online', function(){
|
||||
daemon.cmd('getdifficulty', null, function(result){
|
||||
if (result[0].error != null){
|
||||
callback(result[0].error);
|
||||
return;
|
||||
}
|
||||
profitStatus[profitSymbols[symbol]][symbol].difficulty = result[0].response;
|
||||
|
||||
daemon.cmd('getblocktemplate',
|
||||
[{"capabilities": [ "coinbasetxn", "workid", "coinbase/append" ]}],
|
||||
function(result){
|
||||
if (result[0].error != null){
|
||||
callback(result[0].error);
|
||||
return;
|
||||
}
|
||||
profitStatus[profitSymbols[symbol]][symbol].reward = new Number(result[0].response.coinbasevalue / 100000000);
|
||||
});
|
||||
callback(null)
|
||||
});
|
||||
}).once('connectionFailed', function(error){
|
||||
callback(error);
|
||||
}).on('error', function(error){
|
||||
callback(error);
|
||||
}).init();
|
||||
};
|
||||
|
||||
|
||||
var checkProfitability = function(){
|
||||
logger.debug(logSystem, 'Check', 'Running profitability checks.');
|
||||
logger.debug(logSystem, 'Check', 'Running mining profitability check.');
|
||||
|
||||
async.parallel([
|
||||
_this.getProfitDataPoloniex,
|
||||
_this.getProfitDataCryptsy
|
||||
_this.getProfitDataCryptsy,
|
||||
_this.getCoindDaemonInfo
|
||||
], function(err){
|
||||
if (err){
|
||||
logger.error(logSystem, 'Check', 'Error while checking profitability: ' + err);
|
||||
|
|
Loading…
Reference in New Issue