From 0f38fd5549f38c80125e163528e3d9b9216570d8 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 26 Feb 2014 22:56:47 -0700 Subject: [PATCH] Fixed bug where block was not being reported as found when it actually was --- lib/pool.js | 8 +++++--- lib/stratum.js | 19 ++----------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 02cd644..be2ef94 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -376,10 +376,11 @@ var pool = module.exports = function pool(options, authorizeFn){ function CheckBlockAccepted(blockHash, callback){ _this.daemon.cmd('getblock', [blockHash], - function(error, result){ - if (error) + function(error, results){ + if (error){ callback(false); - else if (result.hash === blockHash) + } + else if (results.filter(function(result){return result.hash === blockHash}).length >= 1) callback(true); else callback(false); @@ -387,6 +388,7 @@ var pool = module.exports = function pool(options, authorizeFn){ ); } + /** * This method is being called from the blockNotify so that when a new block is discovered by the daemon * We can inform our miners about the newly found block diff --git a/lib/stratum.js b/lib/stratum.js index 8048499..0303323 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -195,16 +195,8 @@ var StratumClient = function(options){ } this.enqueueNextDifficulty = function(requestedNewDifficulty) { - if (typeof(requestedNewDifficulty) != 'number') { - console.error('[StratumClient.enqueueNextDifficulty] given difficulty parameter is not a number: ['+requestedNewDifficulty+']'); - return false; - } else { - console.log('[StratumClient.enqueueNextDifficulty] next difficulty should be: ['+requestedNewDifficulty+']'); - pendingDifficulty = requestedNewDifficulty; - return true; - } - - + pendingDifficulty = requestedNewDifficulty; + return true; }; //public members @@ -214,11 +206,6 @@ var StratumClient = function(options){ * returns boolean **/ this.sendDifficulty = function(difficulty){ - if (typeof(difficulty) != 'number') { - console.error('[StratumClient.sendDifficulty] given difficulty parameter is not a number: ['+difficulty+']'); - return false; - } - if (difficulty === this.difficulty) return false; @@ -229,8 +216,6 @@ var StratumClient = function(options){ params: [difficulty]//[512], }); return true; - - }; this.sendMiningJob = function(jobParams){