1) Updated x11 to more accurate diff. 2) Low diff shares report percent off now - to detect if diff is too hard or you just have abusing miners. 3) Only 1 thread does the rpc calls to generate blockchain sync status
This commit is contained in:
parent
8505ca6c50
commit
244d3a406d
@ -1,11 +1,6 @@
|
||||
var bignum = require('bignum');
|
||||
|
||||
var multiHashing = require('multi-hashing');
|
||||
var util = require('./util.js');
|
||||
|
||||
var maxInt256 = global.maxDiff = bignum('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16);
|
||||
|
||||
|
||||
|
||||
var algos = module.exports = global.algos = {
|
||||
sha256: {
|
||||
@ -38,7 +33,7 @@ var algos = module.exports = global.algos = {
|
||||
},
|
||||
x11: {
|
||||
shift: 20,
|
||||
multiplier: Math.pow(2, 30),
|
||||
multiplier: Math.pow(2, 32.3),
|
||||
hash: function(){
|
||||
return multiHashing.x11.apply(this, arguments);
|
||||
}
|
||||
@ -66,7 +61,7 @@ var algos = module.exports = global.algos = {
|
||||
shift: 24,
|
||||
multiplier: Math.pow(2, 8),
|
||||
hash: function(){
|
||||
return multiHashing.bcrypt.apply(this, arguments);
|
||||
return multiHashing.keccak.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
blake: {
|
||||
@ -95,24 +90,41 @@ var algos = module.exports = global.algos = {
|
||||
}
|
||||
};
|
||||
|
||||
//Creates a non-truncated max difficulty (diff1) by bitwise right-shifting the max value of a uint256
|
||||
function ShiftMax256Right(shiftRight){
|
||||
|
||||
//Max value uint256 (an array of ones representing 256 enabled bits)
|
||||
var arr256 = Array.apply(null, new Array(256)).map(Number.prototype.valueOf, 1);
|
||||
|
||||
//An array of zero bits for how far the max uint256 is shifted right
|
||||
var arrLeft = Array.apply(null, new Array(shiftRight)).map(Number.prototype.valueOf, 0);
|
||||
var preShift = arrLeft.concat(arr256);
|
||||
var trimmed = preShift.slice(0, 256);
|
||||
|
||||
//Add zero bits to uint256 and remove the bits shifted out
|
||||
arr256 = arrLeft.concat(arr256).slice(0, 256);
|
||||
|
||||
//An array of bytes to convert the bits to, 8 bits in a byte so length will be 32
|
||||
var octets = [];
|
||||
|
||||
for (var i = 0; i < 32; i++){
|
||||
|
||||
octets[i] = 0;
|
||||
var bits = trimmed.slice(i * 8, i * 8 + 8);
|
||||
|
||||
//The 8 bits for this byte
|
||||
var bits = arr256.slice(i * 8, i * 8 + 8);
|
||||
|
||||
//Bit math to add the bits into a byte
|
||||
for (var f = 0; f < bits.length; f++){
|
||||
var multiplier = Math.pow(2, f);
|
||||
octets[i] += bits[f] * multiplier;
|
||||
}
|
||||
|
||||
}
|
||||
var buff = new Buffer(octets);
|
||||
return buff;
|
||||
|
||||
//return in form of buffer
|
||||
return new Buffer(octets);;
|
||||
}
|
||||
|
||||
for (var algo in algos){
|
||||
algos[algo].diff = ShiftMax256Right(algos[algo].shift);
|
||||
if (!algos[algo].diff)
|
||||
algos[algo].diff = ShiftMax256Right(algos[algo].shift);
|
||||
}
|
||||
@ -31,7 +31,7 @@ function DaemonInterface(options){
|
||||
if (online)
|
||||
_this.emit('online');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function isOnline(callback){
|
||||
cmd('getinfo', [], function(results){
|
||||
|
||||
@ -188,7 +188,8 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
||||
else {
|
||||
var targetUser = maxDifficulty.div(difficulty);
|
||||
if (headerBigNum.gt(targetUser)){
|
||||
return shareError([23, 'low difficulty share']);
|
||||
var lowPercent = targetUser.div(headerBigNum).mul(100).toNumber().toFixed(2);
|
||||
return shareError([23, 'low difficulty share, need to be ' + lowPercent + ' higher']);
|
||||
}
|
||||
}
|
||||
if (!!blockHex) {
|
||||
|
||||
12
lib/pool.js
12
lib/pool.js
@ -142,7 +142,10 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
else{
|
||||
if (displayNotSynced) displayNotSynced();
|
||||
setTimeout(checkSynced, 5000);
|
||||
generateProgress();
|
||||
|
||||
//Only let the first fork show synced status or the log wil look flooded with it
|
||||
if (!process.env.forkId || process.env.forkId === '0')
|
||||
generateProgress();
|
||||
}
|
||||
|
||||
});
|
||||
@ -166,14 +169,11 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
|
||||
var peers = results[0].response;
|
||||
var totalBlocks = peers.sort(function(a, b){
|
||||
return a.startingheight - b.startingheight;
|
||||
return b.startingheight - a.startingheight;
|
||||
})[0].startingheight;
|
||||
|
||||
var percent = (blockCount / totalBlocks * 100).toFixed(2);
|
||||
|
||||
//Only let the first fork show synced status or the log wil look flooded with it
|
||||
if (!process.env.forkId || process.env.forkId === '0')
|
||||
emitWarningLog('Downloaded ' + percent + '% of blockchain from ' + peers.length + ' peers');
|
||||
emitWarningLog('Downloaded ' + percent + '% of blockchain from ' + peers.length + ' peers');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user