From 79c1a95b59c6acc2b7e6d3a02066e1da29dd93ab Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 26 Feb 2014 21:21:41 -0700 Subject: [PATCH] Switch vardiff.mode to safe by default. --- README.md | 9 ++++++--- lib/blockTemplate.js | 2 +- lib/pool.js | 18 +++++++++--------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b8d2f46..0862162 100644 --- a/README.md +++ b/README.md @@ -126,9 +126,12 @@ var pool = stratum.createPool({ retargetTime: 120, //check to see if we should retarget every this many seconds variancePercent: 20 //allow average time to very this % from target without retarget - /* Enabling this option will queue client difficulty updates to be sent when a new job - is available. Otherwise new difficulties will be sent immediately. */ - //mode: 'safe' + /* By default new difficulties will be sent when a new job is available as stratum + protocol (http://mining.bitcoin.cz/stratum-mining) states that new difficulties + "will be applied to every next job received from the server." Some miner software + will almost immediately apply new difficulties. Set mode to fast for difficulty + to be sent immediately. */ + //mode: 'fast' } }, function(ip, workerName, password, callback){ //stratum authorization function diff --git a/lib/blockTemplate.js b/lib/blockTemplate.js index 1045f04..3253178 100644 --- a/lib/blockTemplate.js +++ b/lib/blockTemplate.js @@ -48,7 +48,7 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, publ })); this.merkleTree = new merkleTree(getTransactionBuffers(rpcData.transactions)); this.merkleBranch = getMerkleHashes(this.merkleTree.steps); - this.generationTransaction = transactions.CreateGeneration(//new transactions.Generation( + this.generationTransaction = transactions.CreateGeneration( rpcData, publicKey, extraNoncePlaceholder, diff --git a/lib/pool.js b/lib/pool.js index 0a728d5..02cd644 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -66,20 +66,20 @@ var pool = module.exports = function pool(options, authorizeFn){ _this.varDiff = new varDiff(options.varDiff, options.difficulty); _this.varDiff.on('newDifficulty', function(client, newDiff) { - if (options.varDiff.mode === 'safe'){ - /* We request to set the newDiff @ the next difficulty retarget - (which should happen when a new job comes in - AKA BLOCK) */ - client.enqueueNextDifficulty(newDiff); - } - else{ + if (options.varDiff.mode === 'fast'){ /* Send new difficulty, then force miner to use new diff by resending the - current job parameters but with the "clean jobs" flag set to false - so the miner doesn't restart work and submit duplicate shares */ + current job parameters but with the "clean jobs" flag set to false + so the miner doesn't restart work and submit duplicate shares */ client.sendDifficulty(newDiff); var job = _this.jobManager.currentJob.getJobParams(); - //job[8] = false; + job[8] = false; client.sendMiningJob(job); } + else{ + /* We request to set the newDiff @ the next difficulty retarget + (which should happen when a new job comes in - AKA BLOCK) */ + client.enqueueNextDifficulty(newDiff); + } }); emitLog("system", "VarDiff enabled and setup"); }