From 54b73dd0df2c0b219d01141713cb09f8802f2c33 Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Thu, 3 Apr 2014 14:38:40 -0600 Subject: [PATCH 1/2] Added low share diff tolerance. --- README.md | 6 ++++++ lib/jobManager.js | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 698c364..24666f0 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,12 @@ var pool = Stratum.createPool({ /* Sometimes you want the block hashes even for shares that aren't block candidates. */ "emitInvalidBlockHashes": false, + /* We use proper maximum algorithm difficulties found in the coin daemon source code. Most + miners/pools that deal with scrypt use a guesstimated one that is about 5.86% off from the + actual one. So here we can set a tolerable threshold for if a share is slightly too low + due to mining apps using incorrect max diffs and this pool using correct max diffs. */ + "shareVariancePercent": 10, + /* If a worker is submitting a good deal of invalid shares we can temporarily ban them to reduce system/network load. Also useful to fight against flooding attacks. */ "banning": { diff --git a/lib/jobManager.js b/lib/jobManager.js index 2da22b5..2c6e693 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -182,8 +182,9 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest, var blockHash; var blockHex; - var shareDiff = maxDifficulty.div(headerBigNum).toString(); + var shareDiff = maxDifficulty.div(headerBigNum); + //Check if share is a block candidate (matched network difficulty) if (job.target.ge(headerBigNum)){ blockHex = job.serializeBlock(headerBuffer, coinbaseBuffer).toString('hex'); blockHash = util.reverseBuffer(util.sha256d(headerBuffer)).toString('hex'); @@ -192,20 +193,25 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest, if (options.emitInvalidBlockHashes) blockHashInvalid = util.reverseBuffer(util.sha256d(headerBuffer)).toString('hex'); + //Difficulty the miner is set to var targetUser = maxDifficulty.div(difficulty); + + //Check if share didn't reached the miner's difficulty) if (headerBigNum.gt(targetUser)){ - //Check if share matched a previous difficulty from before vardiff retarget + + //Check if share matched a previous difficulty from before a vardiff retarget if (previousDifficulty && !headerBigNum.gt(maxDifficulty.div(previousDifficulty))){ difficulty = previousDifficulty; } else{ - var offPercent = targetUser.div(headerBigNum).toNumber() * 100; + var offPercent = 100 - (shareDiff.toNumber() / difficulty) * 100; - if (offPercent > options.shareVariancePercent){ - return shareError([23, 'low difficulty share of ' + shareDiff]); + //Check to see if low diff share is within acceptable configured range + if (offPercent > (options.shareVariancePercent || 0)){ + return shareError([23, 'low difficulty share of ' + shareDiff.toString()]); } else{ - _this.emit('log', 'warning', 'Share accepted a low diff ' + shareDiff + ' off by ' + (100 - offPercent).toFixed(2) + '%'); + _this.emit('log', 'warning', 'Share accepted a low diff ' + shareDiff + ' off by ' + offPercent.toFixed(2) + '%'); } } From dfe459c31a48f703aa1f7a0c2db0ac945afc5eca Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Fri, 4 Apr 2014 14:11:01 -0600 Subject: [PATCH 2/2] Minor readame change --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 24666f0..777b71a 100644 --- a/README.md +++ b/README.md @@ -315,14 +315,14 @@ Donations --------- To support development of this project feel free to donate :) -* BTC: 1KRotMnQpxu3sePQnsVLRy3EraRFYfJQFR -* LTC: LKfavSDJmwiFdcgaP1bbu46hhyiWw5oFhE -* VTC: VgW4uFTZcimMSvcnE4cwS3bjJ6P8bcTykN -* MAX: mWexUXRCX5PWBmfh34p11wzS5WX2VWvTRT -* QRK: QehPDAhzVQWPwDPQvmn7iT3PoFUGT7o8bC -* DRK: XcQmhp8ANR7okWAuArcNFZ2bHSB81jpapQ -* DOGE: DBGGVtwAAit1NPZpRm5Nz9VUFErcvVvHYW -* Cryptsy Trade Key: 254ca13444be14937b36c44ba29160bd8f02ff76 +* BTC: `1KRotMnQpxu3sePQnsVLRy3EraRFYfJQFR` +* LTC: `LKfavSDJmwiFdcgaP1bbu46hhyiWw5oFhE` +* VTC: `VgW4uFTZcimMSvcnE4cwS3bjJ6P8bcTykN` +* MAX: `mWexUXRCX5PWBmfh34p11wzS5WX2VWvTRT` +* QRK: `QehPDAhzVQWPwDPQvmn7iT3PoFUGT7o8bC` +* DRK: `XcQmhp8ANR7okWAuArcNFZ2bHSB81jpapQ` +* DOGE: `DBGGVtwAAit1NPZpRm5Nz9VUFErcvVvHYW` +* Cryptsy Trade Key: `254ca13444be14937b36c44ba29160bd8f02ff76` License -------