Removed debuglogging
Moved the difficultyChanged code
This commit is contained in:
parent
3ed4e93b5f
commit
969292c111
@ -152,7 +152,6 @@ var JobManager = module.exports = function JobManager(options){
|
||||
};
|
||||
|
||||
this.processShare = function(jobId, difficulty, extraNonce1, extraNonce2, nTime, nonce, ipAddress, workerName){
|
||||
console.log(difficulty);
|
||||
var shareError = function(error){
|
||||
_this.emit('share', {
|
||||
job: jobId,
|
||||
|
||||
@ -139,10 +139,7 @@ var StratumClient = function(options){
|
||||
});
|
||||
}
|
||||
);
|
||||
if (_this.lastEmittedDiff !== _this.currentDifficulty){
|
||||
_this.lastEmittedDiff = _this.currentDifficulty
|
||||
_this.emit('difficultyChanged', _this.currentDifficulty);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function sendJson(){
|
||||
@ -234,8 +231,11 @@ var StratumClient = function(options){
|
||||
|
||||
this.sendMiningJob = function(jobParams){
|
||||
if (pendingDifficulty !== null){
|
||||
_this.sendDifficulty(pendingDifficulty);
|
||||
var result = _this.sendDifficulty(pendingDifficulty);
|
||||
pendingDifficulty = null;
|
||||
if (result) {
|
||||
_this.emit('difficultyChanged', _this.difficulty);
|
||||
}
|
||||
}
|
||||
sendJson({
|
||||
id : null,
|
||||
|
||||
@ -42,7 +42,6 @@ function RingBuffer(maxSize){
|
||||
|
||||
|
||||
var varDiff = module.exports = function varDiff(options, poolDifficulty){
|
||||
console.log(options);
|
||||
var _this = this;
|
||||
|
||||
var networkDifficulty;
|
||||
@ -78,7 +77,7 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){
|
||||
lastRtc = ts - options.retargetTime / 2;
|
||||
lastTs = ts;
|
||||
timeBuffer = new RingBuffer(bufferSize);
|
||||
console.log(bufferSize+ ' first time share vardiff curdiff: '+client.difficulty);
|
||||
// console.log(bufferSize+ ' first time share vardiff curdiff: '+client.difficulty);
|
||||
return;
|
||||
}
|
||||
var sinceLast = ts - lastTs;
|
||||
@ -87,7 +86,7 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){
|
||||
lastTs = ts;
|
||||
|
||||
if ((ts - lastRtc) < options.retargetTime && timeBuffer.size() > 0){
|
||||
console.log('do not retarget');
|
||||
// console.log('do not retarget');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -107,15 +106,15 @@ var varDiff = module.exports = function varDiff(options, poolDifficulty){
|
||||
|
||||
var diffMax = networkDifficulty < options.maxDifficulty ? networkDifficulty : options.maxDifficulty;
|
||||
var diffMax = options.maxDifficulty;
|
||||
console.log("Max & network", diffMax, networkDifficulty);
|
||||
// console.log("Max & network", diffMax, networkDifficulty);
|
||||
if (ddiff * client.difficulty > diffMax) {
|
||||
ddiff = diffMax / client.difficulty;
|
||||
}
|
||||
|
||||
console.log('increasing difficulty, ddiff: ' + ddiff);
|
||||
// console.log('increasing difficulty, ddiff: ' + ddiff);
|
||||
}
|
||||
else{
|
||||
console.log('hashrate in range ' + JSON.stringify({ddiff: ddiff, avg: avg}) );
|
||||
// console.log('hashrate in range ' + JSON.stringify({ddiff: ddiff, avg: avg}) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user