Fixed block solutions not being reported

This commit is contained in:
Matt 2014-04-18 13:33:17 -06:00
parent 3db1b47199
commit a4b087cec4
4 changed files with 18 additions and 16 deletions

View File

@ -289,9 +289,11 @@ Listen to pool events
reward: 5000000000, //the number of satoshis received as payment for solving this block
difficulty: 64, //stratum worker difficulty
shareDiff: 78, //actual difficulty of the share
blockDiff: 3349 //difficulty for this block
blockDiff: 3349, //block difficulty adjusted for share padding
blockDiffActual: 3349 //actual difficulty for this block
//AAK the block solution - set if block was found
//AKA the block solution - set if block was found
blockHash: '110c0447171ad819dd181216d5d80f41e9218e25d833a2789cb8ba289a52eee4',
//Exists if "emitInvalidBlockHashes" is set to true

View File

@ -71,7 +71,9 @@ var JobManager = module.exports = function JobManager(maxDifficulty, options){
switch(options.coin.algorithm){
case 'keccak':
case 'blake':
if (options.coin.normalHashing !== true)
if (options.coin.normalHashing === true)
return util.sha256d;
else
return util.sha256;
default:
return util.sha256d;
@ -82,13 +84,12 @@ var JobManager = module.exports = function JobManager(maxDifficulty, options){
switch(options.coin.algorithm){
case 'keccak':
case 'blake':
//if (options.coin.normalHashing !== true)
return function(d, nTime){
util.reverseBuffer(util.sha256d(Buffer.concat([d, new Buffer(nTime, 'hex')])));
};
return function(d, nTime){
return util.reverseBuffer(util.sha256d(Buffer.concat([d, new Buffer(nTime, 'hex')])));
};
default:
return function(d){
util.reverseBuffer(util.sha256d(d));
return util.reverseBuffer(util.sha256d(d));
};
}
})();
@ -212,10 +213,12 @@ var JobManager = module.exports = function JobManager(maxDifficulty, options){
maxDifficulty.toNumber() / headerBigNum.toNumber() :
maxDifficulty.div(headerBigNum).toNumber();
var blockDiffAdjusted = maxDifficulty.toNumber() / job.target.toNumber();
//Check if share is a block candidate (matched network difficulty)
if (job.target.ge(headerBigNum)){
blockHex = job.serializeBlock(headerBuffer, coinbaseBuffer).toString('hex');
blockHash = blockHasher(headerBuffer, nTime)
blockHash = blockHasher(headerBuffer, nTime).toString('hex');
}
else {
if (options.emitInvalidBlockHashes)
@ -253,7 +256,8 @@ var JobManager = module.exports = function JobManager(maxDifficulty, options){
reward: job.rpcData.coinbasevalue,
difficulty: difficulty,
shareDiff: shareDiff,
blockDiff : job.difficulty,
blockDiff : blockDiffAdjusted,
blockDiffActual: job.difficulty,
blockHash: blockHash,
blockHashInvalid: blockHashInvalid
}, blockHex);

View File

@ -51,8 +51,6 @@ var pool = module.exports = function pool(options, authorizeFn){
//Which number to use as dividend when converting difficulty to target
var maxDifficulty = algos[options.coin.algorithm].maxDiff;
console.log(options.coin.name + ' ' + maxDifficulty.toString(16));
this.start = function(){
@ -306,8 +304,6 @@ var pool = module.exports = function pool(options, authorizeFn){
}
}).on('log', function(severity, message){
_this.emit('log', severity, message);
}).on('debugBlockShare', function(debugData) {
//emitLog(JSON.stringify(debugData));
});
}

View File

@ -408,6 +408,7 @@ var StratumServer = exports.Server = function StratumServer(options, authorizeFn
}
}
(function init(){
//Interval to look through bannedIPs for old bans and remove them in order to prevent a memory leak
@ -450,7 +451,6 @@ var StratumServer = exports.Server = function StratumServer(options, authorizeFn
}*/
};
this.getStratumClients = function () {
return stratumClients;
};
@ -465,7 +465,7 @@ var StratumServer = exports.Server = function StratumServer(options, authorizeFn
stratumClients[subId].manuallyAuthClient(clientObj.workerName, clientObj.workerPass);
stratumClients[subId].manuallySetValues(clientObj);
}
}
};
};
StratumServer.prototype.__proto__ = events.EventEmitter.prototype;