Made scrypt-n have configurable timeTables.
This commit is contained in:
parent
63c4f68da8
commit
4007a7e30c
@ -7,85 +7,129 @@ var algos = module.exports = global.algos = {
|
||||
shift: 32,
|
||||
multiplier: Math.pow(2, 32),
|
||||
hash: function(){
|
||||
return util.doublesha.apply(this, arguments);
|
||||
return function(){
|
||||
return util.doublesha.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
scrypt: {
|
||||
shift: 20,
|
||||
multiplier: Math.pow(2, 16),
|
||||
hash: function(){
|
||||
return multiHashing.scrypt.apply(this, arguments);
|
||||
return function(){
|
||||
return multiHashing.scrypt.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
'scrypt-jane': {
|
||||
shift: 20,
|
||||
multiplier: Math.pow(2, 16),
|
||||
hash: function(){
|
||||
return multiHashing.scryptjane.apply(this, arguments);
|
||||
hash: function(coinConfig){
|
||||
var nTimestamp = coinConfig.chainStartTime || 1367991200;
|
||||
var nMin = coinConfig.nMin || 4;
|
||||
var nMax = coinConfig.nMax || 30;
|
||||
return function(data, nTime){
|
||||
return multiHashing.scryptjane(data, nTime, nTimestamp, nMin, nMax);
|
||||
}
|
||||
}
|
||||
},
|
||||
'scrypt-n': {
|
||||
shift: 20,
|
||||
multiplier: Math.pow(2, 16),
|
||||
hash: function(){
|
||||
return multiHashing.scryptn.apply(this, arguments);
|
||||
hash: function(coinConfig){
|
||||
|
||||
var timeTable = coinConfig.timeTable || {
|
||||
"2048": 1389306217, "4096": 1456415081, "8192": 1506746729, "16384": 1557078377, "32768": 1657741673,
|
||||
"65536": 1859068265, "131072": 2060394857, "262144": 1722307603, "524288": 1769642992
|
||||
};
|
||||
|
||||
var nFactor = (function(){
|
||||
var n = Object.keys(timeTable).sort().reverse().filter(function(nKey){
|
||||
return Date.now() / 1000 > timeTable[nKey];
|
||||
})[0];
|
||||
|
||||
var nInt = parseInt(n);
|
||||
return Math.log(nInt) / Math.log(2);
|
||||
})();
|
||||
|
||||
return function(data) {
|
||||
return multiHashing.scryptn(data, nFactor);
|
||||
}
|
||||
}
|
||||
},
|
||||
x11: {
|
||||
shift: 20,
|
||||
multiplier: Math.pow(2, 32.3),
|
||||
hash: function(){
|
||||
return multiHashing.x11.apply(this, arguments);
|
||||
return function(){
|
||||
return multiHashing.x11.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
quark: {
|
||||
shift: 20,
|
||||
multipler: Math.pow(2, 16),
|
||||
hash: function(){
|
||||
return multiHashing.quark.apply(this, arguments);
|
||||
return function(){
|
||||
return multiHashing.quark.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
skein: {
|
||||
shift: 20,
|
||||
hash: function(){
|
||||
return multiHashing.skein.apply(this, arguments);
|
||||
return function(){
|
||||
return multiHashing.skein.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
bcrypt: {
|
||||
shift: 11,
|
||||
hash: function(){
|
||||
return multiHashing.bcrypt.apply(this, arguments);
|
||||
return function(){
|
||||
return multiHashing.bcrypt.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
keccak: {
|
||||
shift: 24,
|
||||
multiplier: Math.pow(2, 8),
|
||||
hash: function(){
|
||||
return multiHashing.keccak.apply(this, arguments);
|
||||
return function(){
|
||||
return multiHashing.keccak.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
blake: {
|
||||
shift: 24,
|
||||
hash: function(){
|
||||
return function(){
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
fugue: {
|
||||
shift: 24,
|
||||
hash: function(){
|
||||
return function(){
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
shavite: {
|
||||
shift: 20,
|
||||
hash: function(){
|
||||
return function(){
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
hefty1: {
|
||||
shift: 16,
|
||||
hash: function(){
|
||||
return function(){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -173,7 +173,7 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
||||
var merkleRoot = util.reverseBuffer(job.merkleTree.withFirst(coinbaseHash)).toString('hex');
|
||||
|
||||
var headerBuffer = job.serializeHeader(merkleRoot, nTime, nonce);
|
||||
var headerHash = hashDigest(headerBuffer, nTimeInt, options.coin.chainTime);
|
||||
var headerHash = hashDigest(headerBuffer, nTimeInt);
|
||||
var headerBigNum = bignum.fromBuffer(headerHash, {endian: 'little', size: 32});
|
||||
|
||||
var blockHash;
|
||||
|
||||
@ -47,7 +47,7 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
//Which number to use as dividend when converting difficulty to target
|
||||
var maxDifficulty = bignum.fromBuffer(algos[options.coin.algorithm].diff);
|
||||
|
||||
var hashDigest = algos[options.coin.algorithm].hash;
|
||||
var hashDigest = algos[options.coin.algorithm].hash(options.coin);
|
||||
|
||||
|
||||
this.start = function(){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user