From 8806aa8896d0d09bafc09a1199e74a2557faeca4 Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Fri, 18 Apr 2014 21:41:55 -0600 Subject: [PATCH] Fixed block hash generation for various algos --- lib/algoProperties.js | 42 +++++++++++++++++++++--------------------- lib/jobManager.js | 10 ++++++++-- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lib/algoProperties.js b/lib/algoProperties.js index 351f2cb..9e51843 100644 --- a/lib/algoProperties.js +++ b/lib/algoProperties.js @@ -84,41 +84,33 @@ var algos = module.exports = global.algos = { }; } else { - return function (data) { - return multiHashing.keccak(data); + return function () { + return multiHashing.keccak.apply(this, arguments); } } } }, + blake: { + multiplier: Math.pow(2, 24), + hash: function(){ + return function(){ + return multiHashing.blake.apply(this, arguments); + } + } + }, skein: { - multiplier: Math.pow(2, 16), + multiplier: Math.pow(2, 24), hash: function(){ return function(){ return multiHashing.skein.apply(this, arguments); } } }, - bcrypt: { - shift: 11, - hash: function(){ - return function(){ - return multiHashing.bcrypt.apply(this, arguments); - } - } - }, - blake: { - shift: 24, - hash: function(){ - return function(){ - - } - } - }, fugue: { - shift: 24, + multiplier: Math.pow(2, 24), hash: function(){ return function(){ - + return multiHashing.fugue.apply(this, arguments); } } }, @@ -137,6 +129,14 @@ var algos = module.exports = global.algos = { } } + }, + bcrypt: { + shift: 11, + hash: function(){ + return function(){ + return multiHashing.bcrypt.apply(this, arguments); + } + } } }; diff --git a/lib/jobManager.js b/lib/jobManager.js index daaf2f9..32ed375 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -71,6 +71,8 @@ var JobManager = module.exports = function JobManager(maxDifficulty, options){ switch(options.coin.algorithm){ case 'keccak': case 'blake': + case 'skein': + case 'fugue': if (options.coin.normalHashing === true) return util.sha256d; else @@ -82,10 +84,14 @@ var JobManager = module.exports = function JobManager(maxDifficulty, options){ var blockHasher = (function(){ switch(options.coin.algorithm){ + case 'x11': + case 'quark': case 'keccak': + case 'skein': + case 'fugue': case 'blake': - return function(d, nTime){ - return util.reverseBuffer(util.sha256d(Buffer.concat([d, new Buffer(nTime, 'hex')]))); + return function(){ + return util.reverseBuffer(hashDigest.apply(this, arguments)); }; default: return function(d){