Fixed block hash generation for various algos

This commit is contained in:
Matthew Little 2014-04-18 21:41:55 -06:00
parent 7b24ce543d
commit 8806aa8896
2 changed files with 29 additions and 23 deletions

View File

@ -84,41 +84,33 @@ var algos = module.exports = global.algos = {
}; };
} }
else { else {
return function (data) { return function () {
return multiHashing.keccak(data); return multiHashing.keccak.apply(this, arguments);
} }
} }
} }
}, },
blake: {
multiplier: Math.pow(2, 24),
hash: function(){
return function(){
return multiHashing.blake.apply(this, arguments);
}
}
},
skein: { skein: {
multiplier: Math.pow(2, 16), multiplier: Math.pow(2, 24),
hash: function(){ hash: function(){
return function(){ return function(){
return multiHashing.skein.apply(this, arguments); 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: { fugue: {
shift: 24, multiplier: Math.pow(2, 24),
hash: function(){ hash: function(){
return 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);
}
}
} }
}; };

View File

@ -71,6 +71,8 @@ var JobManager = module.exports = function JobManager(maxDifficulty, options){
switch(options.coin.algorithm){ switch(options.coin.algorithm){
case 'keccak': case 'keccak':
case 'blake': case 'blake':
case 'skein':
case 'fugue':
if (options.coin.normalHashing === true) if (options.coin.normalHashing === true)
return util.sha256d; return util.sha256d;
else else
@ -82,10 +84,14 @@ var JobManager = module.exports = function JobManager(maxDifficulty, options){
var blockHasher = (function(){ var blockHasher = (function(){
switch(options.coin.algorithm){ switch(options.coin.algorithm){
case 'x11':
case 'quark':
case 'keccak': case 'keccak':
case 'skein':
case 'fugue':
case 'blake': case 'blake':
return function(d, nTime){ return function(){
return util.reverseBuffer(util.sha256d(Buffer.concat([d, new Buffer(nTime, 'hex')]))); return util.reverseBuffer(hashDigest.apply(this, arguments));
}; };
default: default:
return function(d){ return function(d){