Re-add support for pre V10 Codebase Coin Mining (#150)

This commit is contained in:
ahmedbodi 2018-06-23 23:19:35 +01:00 committed by Matthew Little
parent 60c88a7c5f
commit 4f298c3ead
2 changed files with 17 additions and 8 deletions

View File

@ -37,7 +37,7 @@ function DaemonInterface(daemons, logger){
}
function isOnline(callback){
cmd('getnetworkinfo', [], function(results){
cmd('getpeerinfo', [], function(results){
var allOnline = results.every(function(result){
return !results.error;
});

View File

@ -146,7 +146,8 @@ var pool = module.exports = function pool(options, authorizeFn){
var generateProgress = function(){
_this.daemon.cmd('getblockchaininfo', [], function(results) {
var cmd = options.coin.hasGetInfo ? 'getinfo' : 'getblockchaininfo';
_this.daemon.cmd(cmd, [], function(results) {
var blockCount = results.sort(function (a, b) {
return b.response.blocks - a.response.blocks;
})[0].response.blocks;
@ -369,12 +370,15 @@ var pool = module.exports = function pool(options, authorizeFn){
var batchRpcCalls = [
['validateaddress', [options.address]],
['getdifficulty', []],
['getblockchaininfo', []],
['getnetworkinfo', []],
['getmininginfo', []],
['submitblock', []]
];
if (options.coin.hasGetInfo) {
batchRpcCalls.push(['getinfo', []]);
} else {
batchRpcCalls.push(['getblockchaininfo', []], ['getnetworkinfo', []]);
}
_this.daemon.batchCmd(batchRpcCalls, function(error, results){
if (error || !results){
emitErrorLog('Could not start pool, error with init batch RPC call: ' + JSON.stringify(error));
@ -423,13 +427,18 @@ var pool = module.exports = function pool(options, authorizeFn){
}
})();
options.testnet = (rpcResults.getblockchaininfo.chain === 'test') ? true : false;
options.testnet = options.coin.hasGetInfo ? rpcResults.getinfo.testnet : (rpcResults.getblockchaininfo.chain === 'test') ? true : false;
options.protocolVersion = rpcResults.getnetworkinfo.protocolversion;
options.protocolVersion = options.coin.hasGetInfo ? rpcResults.getinfo.protocolversion : rpcResults.getnetworkinfo.protocolversion;
var difficulty = options.coin.hasGetInfo ? rpcResults.getinfo.difficulty : rpcResults.getblockchaininfo.difficulty;
if (typeof(difficulty) == 'object') {
difficulty = difficulty['proof-of-work'];
}
options.initStats = {
connections: rpcResults.getnetworkinfo.connections,
difficulty: rpcResults.getblockchaininfo.difficulty * algos[options.coin.algorithm].multiplier,
connections: (options.coin.hasGetInfo ? rpcResults.getinfo.connections : rpcResults.getnetworkinfo.connections),
difficulty: difficulty * algos[options.coin.algorithm].multiplier,
networkHashRate: rpcResults.getmininginfo.networkhashps
};