Fixed a couple of bugs that were preventing the thing to start in case of POS
This commit is contained in:
parent
863c8bbf5f
commit
4fdd4fcf51
52
lib/pool.js
52
lib/pool.js
|
@ -81,6 +81,10 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||
_this.daemon.cmd('submitblock',
|
||||
[blockHex],
|
||||
function(error, result){
|
||||
console.log(JSON.stringify([error,result]));
|
||||
emitLog('submitblock', JSON.stringify([error,result]));
|
||||
|
||||
|
||||
if (error)
|
||||
emitErrorLog('submitblock', 'rpc error when submitting block with submitblock')
|
||||
else
|
||||
|
@ -92,6 +96,7 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||
_this.daemon.cmd('getblocktemplate',
|
||||
[{'mode': 'submit', 'data': blockHex}],
|
||||
function(error, result){
|
||||
console.log(error, result);
|
||||
if (error)
|
||||
emitErrorLog('submitblock', 'rpc error when submitting block with getblocktemplate')
|
||||
else
|
||||
|
@ -182,32 +187,37 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||
|
||||
emitLog('system','Connected to daemon');
|
||||
options.hasSubmitMethod = results.submitMethod;
|
||||
if (options.reward === 'POS' && typeof(results.addressInfo.pubkey) == 'undefined') {
|
||||
// address provided is not of the wallet.
|
||||
emitErrorLog('system', 'The address provided is not from the daemon wallet.');
|
||||
return;
|
||||
} else {
|
||||
publicKeyBuffer = options.reward === 'POW' ?
|
||||
util.script_to_address(results.addressInfo.address) :
|
||||
util.script_to_pubkey(results.addressInfo.pubkey);
|
||||
|
||||
publicKeyBuffer = options.reward === 'POW' ?
|
||||
util.script_to_address(results.addressInfo.address) :
|
||||
util.script_to_pubkey(results.addressInfo.pubkey);
|
||||
if (options.difficulty > results.networkDifficulty && options.difficulty > 16){
|
||||
var newDiff = results.networkDifficulty > 16 ? results.networkDifficulty : 16;
|
||||
emitWarningLog('system', 'pool difficulty was set higher than network difficulty of ' + results.networkDifficulty);
|
||||
emitWarningLog('system', 'lowering pool diff from ' + options.difficulty + ' to ' + newDiff);
|
||||
|
||||
if (options.difficulty > results.networkDifficulty && options.difficulty > 16){
|
||||
var newDiff = results.networkDifficulty > 16 ? results.networkDifficulty : 16;
|
||||
emitWarningLog('system', 'pool difficulty was set higher than network difficulty of ' + results.networkDifficulty);
|
||||
emitWarningLog('system', 'lowering pool diff from ' + options.difficulty + ' to ' + newDiff);
|
||||
options.difficulty = newDiff
|
||||
|
||||
options.difficulty = newDiff
|
||||
if (options.varDiff.enabled)
|
||||
_this.varDiff.setPoolDifficulty(options.difficulty);
|
||||
}
|
||||
|
||||
if (options.varDiff.enabled)
|
||||
_this.varDiff.setPoolDifficulty(options.difficulty);
|
||||
GetBlockTemplate(function(error, result){
|
||||
if (error){
|
||||
console.error(error);
|
||||
emitErrorLog('system', 'Error with initial getblocktemplate');
|
||||
}
|
||||
else{
|
||||
SetupBlockPolling();
|
||||
StartStratumServer();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
GetBlockTemplate(function(error, result){
|
||||
if (error){
|
||||
console.error(error);
|
||||
emitErrorLog('system', 'Error with initial getblocktemplate');
|
||||
}
|
||||
else{
|
||||
SetupBlockPolling();
|
||||
StartStratumServer();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}).on('startFailed', function(){
|
||||
|
|
|
@ -210,7 +210,7 @@ exports.address_to_pubkeyhash = function(addr){
|
|||
*/
|
||||
exports.script_to_pubkey = function(key){
|
||||
if (key.length === 66) key = new Buffer(key, 'hex');
|
||||
if (key !== 33) throw 'Invalid address';
|
||||
if (key.length !== 33) throw 'Invalid address';
|
||||
var pubkey = new Buffer(35);
|
||||
pubkey[0] = 0x21;
|
||||
pubkey[34] = 0xac;
|
||||
|
|
Loading…
Reference in New Issue