Convert diff dividend to bignum only on init.
This commit is contained in:
parent
b26312cf73
commit
69feb04da1
@ -55,7 +55,7 @@ var JobManager = module.exports = function JobManager(options){
|
|||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var jobCounter = new JobCounter();
|
var jobCounter = new JobCounter();
|
||||||
//var jobs = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It only checks if the blockTemplate is already in our jobs list.
|
* It only checks if the blockTemplate is already in our jobs list.
|
||||||
@ -70,20 +70,11 @@ var JobManager = module.exports = function JobManager(options){
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*var newBlock = true;
|
|
||||||
for(var job in jobs){
|
|
||||||
if (jobs[job].rpcData.previousblockhash === prevBlockHash) {
|
|
||||||
newBlock = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newBlock;*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Which number to use as dividend when converting difficulty to target
|
//Which number to use as dividend when converting difficulty to target
|
||||||
var diffDividend = (function(){
|
var diffDividend = bignum((function(){
|
||||||
switch(options.algorithm){
|
switch(options.algorithm){
|
||||||
case 'sha256':
|
case 'sha256':
|
||||||
return '00000000ffff0000000000000000000000000000000000000000000000000000';
|
return '00000000ffff0000000000000000000000000000000000000000000000000000';
|
||||||
@ -94,7 +85,7 @@ var JobManager = module.exports = function JobManager(options){
|
|||||||
case 'x11':
|
case 'x11':
|
||||||
return '000000ffff000000000000000000000000000000000000000000000000000000';
|
return '000000ffff000000000000000000000000000000000000000000000000000000';
|
||||||
}
|
}
|
||||||
})();
|
})(), 16);
|
||||||
|
|
||||||
|
|
||||||
//On initialization lets figure out which hashing algorithm to use
|
//On initialization lets figure out which hashing algorithm to use
|
||||||
@ -144,7 +135,6 @@ var JobManager = module.exports = function JobManager(options){
|
|||||||
options.txMessages
|
options.txMessages
|
||||||
);
|
);
|
||||||
|
|
||||||
//jobs[tmpBlockTemplate.jobId] = tmpBlockTemplate;
|
|
||||||
|
|
||||||
this.currentJob = tmpBlockTemplate;
|
this.currentJob = tmpBlockTemplate;
|
||||||
_this.emit('newBlock', tmpBlockTemplate);
|
_this.emit('newBlock', tmpBlockTemplate);
|
||||||
@ -169,7 +159,6 @@ var JobManager = module.exports = function JobManager(options){
|
|||||||
return shareError([20, 'incorrect size of extranonce2']);
|
return shareError([20, 'incorrect size of extranonce2']);
|
||||||
|
|
||||||
var job = this.currentJob;
|
var job = this.currentJob;
|
||||||
//var job = jobs[jobId];
|
|
||||||
|
|
||||||
if (typeof job === 'undefined' || job.jobId != jobId ) {
|
if (typeof job === 'undefined' || job.jobId != jobId ) {
|
||||||
return shareError([21, 'job not found']);
|
return shareError([21, 'job not found']);
|
||||||
@ -214,7 +203,7 @@ var JobManager = module.exports = function JobManager(options){
|
|||||||
blockHash = util.reverseBuffer(util.doublesha(headerBuffer)).toString('hex');
|
blockHash = util.reverseBuffer(util.doublesha(headerBuffer)).toString('hex');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var targetUser = bignum(diffDividend, 16).div(difficulty);
|
var targetUser = diffDividend.div(difficulty);
|
||||||
if (headerBigNum.gt(targetUser)){
|
if (headerBigNum.gt(targetUser)){
|
||||||
return shareError([23, 'low difficulty share']);
|
return shareError([23, 'low difficulty share']);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user