Accept low shares within a threshold - not finished
This commit is contained in:
parent
b77398c5e2
commit
d8abc4008d
@ -169,7 +169,6 @@ function ShiftMax256Right(shiftRight){
|
||||
|
||||
}
|
||||
|
||||
//return in form of buffer
|
||||
return new Buffer(octets);;
|
||||
}
|
||||
|
||||
@ -202,8 +201,6 @@ function ConvertBitsToBuff(bitsBuff){
|
||||
buff256.fill(0);
|
||||
resultBuff.copy(buff256, buff256.length - resultBuff.length);
|
||||
|
||||
//var hexResult = buff256.toString('hex');
|
||||
//return hexResult;
|
||||
return buff256;
|
||||
}
|
||||
|
||||
@ -216,5 +213,6 @@ for (var algo in algos){
|
||||
algos[algo].bits = compactBits;
|
||||
algos[algo].diff = truncatedDiff;
|
||||
algos[algo].nonTruncatedDiff = nonTruncatedDiff;
|
||||
algos[algo].diff = nonTruncatedDiff;
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
||||
var blockHash;
|
||||
var blockHex;
|
||||
|
||||
|
||||
var shareDiff = maxDifficulty.div(headerBigNum).toString();
|
||||
|
||||
if (job.target.ge(headerBigNum)){
|
||||
blockHex = job.serializeBlock(headerBuffer, coinbaseBuffer).toString('hex');
|
||||
@ -199,8 +199,14 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
||||
difficulty = previousDifficulty;
|
||||
}
|
||||
else{
|
||||
var shareDiff = maxDifficulty.div(headerBigNum).toString();
|
||||
return shareError([23, 'low difficulty share of ' + shareDiff]);
|
||||
var offPercent = targetUser.div(headerBigNum).toNumber() * 100;
|
||||
|
||||
if (offPercent > options.shareVariancePercent){
|
||||
return shareError([23, 'low difficulty share of ' + shareDiff]);
|
||||
}
|
||||
else{
|
||||
_this.emit('log', 'warning', 'Share accepted a low diff ' + shareDiff + ' off by ' + (100 - offPercent).toFixed(2) + '%');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -212,6 +218,7 @@ var JobManager = module.exports = function JobManager(maxDifficulty, hashDigest,
|
||||
ip: ipAddress,
|
||||
worker: workerName,
|
||||
difficulty: difficulty,
|
||||
shareDiff: shareDiff,
|
||||
height: job.rpcData.height,
|
||||
reward: job.rpcData.coinbasevalue,
|
||||
networkDifficulty : job.difficulty.toString(),
|
||||
|
||||
11
lib/pool.js
11
lib/pool.js
@ -296,6 +296,8 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
});
|
||||
});
|
||||
}
|
||||
}).on('log', function(severity, message){
|
||||
_this.emit('log', severity, message);
|
||||
}).on('debugBlockShare', function(debugData) {
|
||||
//emitLog(JSON.stringify(debugData));
|
||||
});
|
||||
@ -559,20 +561,21 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
params.extraNonce2,
|
||||
params.nTime,
|
||||
params.nonce,
|
||||
client.socket.remoteAddress,
|
||||
client.remoteAddress,
|
||||
params.name
|
||||
);
|
||||
|
||||
resultCallback(result.error, result.result ? true : null);
|
||||
|
||||
}).on('malformedMessage', function (message) {
|
||||
emitWarningLog((client.workerName || ('Unauthorized miner [' + client.socket.remoteAddress + ']')) + " has sent us a malformed message: " + message);
|
||||
emitWarningLog((client.workerName || ('Unauthorized miner [' + client.remoteAddress + ']')) + " has sent us a malformed message: " + message);
|
||||
|
||||
}).on('socketError', function(err) {
|
||||
emitWarningLog(client.workerName + " has somehow had a socket error: " + JSON.stringify(err));
|
||||
|
||||
}).on('socketDisconnect', function() {
|
||||
emitLog("Client '" + client.workerName + "' disconnected!");
|
||||
}).on('socketDisconnect', function(){
|
||||
var clientTitle = client.workerName ? ("'" + client.workerName + '"') : '(unauthorized)';
|
||||
emitLog("Client " + clientTitle + ' [' + client.remoteAddress + "] disconnected");
|
||||
|
||||
}).on('unknownStratumMethod', function(fullMessage) {
|
||||
emitLog("Client '" + client.workerName + "' has sent us an unknown stratum method: " + fullMessage.method);
|
||||
|
||||
@ -28,6 +28,8 @@ var StratumClient = function(options){
|
||||
//private members
|
||||
this.socket = options.socket;
|
||||
|
||||
this.remoteAddress = options.remoteAddress;
|
||||
|
||||
var banning = options.banning;
|
||||
|
||||
var _this = this;
|
||||
@ -219,7 +221,7 @@ var StratumClient = function(options){
|
||||
});
|
||||
socket.on('error', function(err){
|
||||
if (err.code === 'ECONNRESET')
|
||||
_this.emit('socketDisconnect')
|
||||
_this.emit('socketDisconnect');
|
||||
else
|
||||
_this.emit('socketError', err);
|
||||
});
|
||||
@ -310,7 +312,7 @@ var StratumServer = exports.Server = function StratumServer(ports, connectionTim
|
||||
}
|
||||
}, 1000 * banning.purgeInterval);
|
||||
|
||||
this.handleNewClient = function (socket) {
|
||||
this.handleNewClient = function (socket){
|
||||
if (banning && banning.enabled && socket.remoteAddress in bannedIPs){
|
||||
var bannedTime = bannedIPs[socket.remoteAddress];
|
||||
if ((Date.now() - bannedTime) < bannedMS){
|
||||
@ -328,11 +330,12 @@ var StratumServer = exports.Server = function StratumServer(ports, connectionTim
|
||||
var subscriptionId = subscriptionCounter.next();
|
||||
var client = new StratumClient(
|
||||
{
|
||||
subscriptionId : subscriptionId,
|
||||
socket : socket,
|
||||
authorizeFn : authorizeFn,
|
||||
banning : banning,
|
||||
socketTimeout : socketTimeout
|
||||
subscriptionId: subscriptionId,
|
||||
socket: socket,
|
||||
authorizeFn: authorizeFn,
|
||||
banning: banning,
|
||||
socketTimeout: socketTimeout,
|
||||
remoteAddress: socket.remoteAddress
|
||||
}
|
||||
);
|
||||
stratumClients[subscriptionId] = client;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user