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,
|
shift: 32,
|
||||||
multiplier: Math.pow(2, 32),
|
multiplier: Math.pow(2, 32),
|
||||||
hash: function(){
|
hash: function(){
|
||||||
return util.doublesha.apply(this, arguments);
|
return function(){
|
||||||
|
return util.doublesha.apply(this, arguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scrypt: {
|
scrypt: {
|
||||||
shift: 20,
|
shift: 20,
|
||||||
multiplier: Math.pow(2, 16),
|
multiplier: Math.pow(2, 16),
|
||||||
hash: function(){
|
hash: function(){
|
||||||
return multiHashing.scrypt.apply(this, arguments);
|
return function(){
|
||||||
|
return multiHashing.scrypt.apply(this, arguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'scrypt-jane': {
|
'scrypt-jane': {
|
||||||
shift: 20,
|
shift: 20,
|
||||||
multiplier: Math.pow(2, 16),
|
multiplier: Math.pow(2, 16),
|
||||||
hash: function(){
|
hash: function(coinConfig){
|
||||||
return multiHashing.scryptjane.apply(this, arguments);
|
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': {
|
'scrypt-n': {
|
||||||
shift: 20,
|
shift: 20,
|
||||||
multiplier: Math.pow(2, 16),
|
multiplier: Math.pow(2, 16),
|
||||||
hash: function(){
|
hash: function(coinConfig){
|
||||||
return multiHashing.scryptn.apply(this, arguments);
|
|
||||||
|
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: {
|
x11: {
|
||||||
shift: 20,
|
shift: 20,
|
||||||
multiplier: Math.pow(2, 32.3),
|
multiplier: Math.pow(2, 32.3),
|
||||||
hash: function(){
|
hash: function(){
|
||||||
return multiHashing.x11.apply(this, arguments);
|
return function(){
|
||||||
|
return multiHashing.x11.apply(this, arguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
quark: {
|
quark: {
|
||||||
shift: 20,
|
shift: 20,
|
||||||
multipler: Math.pow(2, 16),
|
multipler: Math.pow(2, 16),
|
||||||
hash: function(){
|
hash: function(){
|
||||||
return multiHashing.quark.apply(this, arguments);
|
return function(){
|
||||||
|
return multiHashing.quark.apply(this, arguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
skein: {
|
skein: {
|
||||||
shift: 20,
|
shift: 20,
|
||||||
hash: function(){
|
hash: function(){
|
||||||
return multiHashing.skein.apply(this, arguments);
|
return function(){
|
||||||
|
return multiHashing.skein.apply(this, arguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
bcrypt: {
|
bcrypt: {
|
||||||
shift: 11,
|
shift: 11,
|
||||||
hash: function(){
|
hash: function(){
|
||||||
return multiHashing.bcrypt.apply(this, arguments);
|
return function(){
|
||||||
|
return multiHashing.bcrypt.apply(this, arguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
keccak: {
|
keccak: {
|
||||||
shift: 24,
|
shift: 24,
|
||||||
multiplier: Math.pow(2, 8),
|
multiplier: Math.pow(2, 8),
|
||||||
hash: function(){
|
hash: function(){
|
||||||
return multiHashing.keccak.apply(this, arguments);
|
return function(){
|
||||||
|
return multiHashing.keccak.apply(this, arguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
blake: {
|
blake: {
|
||||||
shift: 24,
|
shift: 24,
|
||||||
hash: function(){
|
hash: function(){
|
||||||
|
return function(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fugue: {
|
fugue: {
|
||||||
shift: 24,
|
shift: 24,
|
||||||
hash: function(){
|
hash: function(){
|
||||||
|
return function(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
shavite: {
|
shavite: {
|
||||||
shift: 20,
|
shift: 20,
|
||||||
hash: function(){
|
hash: function(){
|
||||||
|
return function(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hefty1: {
|
hefty1: {
|
||||||
shift: 16,
|
shift: 16,
|
||||||
hash: function(){
|
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 merkleRoot = util.reverseBuffer(job.merkleTree.withFirst(coinbaseHash)).toString('hex');
|
||||||
|
|
||||||
var headerBuffer = job.serializeHeader(merkleRoot, nTime, nonce);
|
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 headerBigNum = bignum.fromBuffer(headerHash, {endian: 'little', size: 32});
|
||||||
|
|
||||||
var blockHash;
|
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
|
//Which number to use as dividend when converting difficulty to target
|
||||||
var maxDifficulty = bignum.fromBuffer(algos[options.coin.algorithm].diff);
|
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(){
|
this.start = function(){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user