|
|
@ -9,6 +9,7 @@ const async = require('async');
|
|
|
|
const net = require('net');
|
|
|
|
const net = require('net');
|
|
|
|
const tls = require('tls');
|
|
|
|
const tls = require('tls');
|
|
|
|
const fs = require('fs');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const multiHashing = require("cryptonight-hashing");
|
|
|
|
|
|
|
|
|
|
|
|
let nonceCheck = new RegExp("^[0-9a-f]{8}$");
|
|
|
|
let nonceCheck = new RegExp("^[0-9a-f]{8}$");
|
|
|
|
let bannedIPs = [];
|
|
|
|
let bannedIPs = [];
|
|
|
@ -216,6 +217,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer
|
|
|
|
// prevent pool crash when pass is null
|
|
|
|
// prevent pool crash when pass is null
|
|
|
|
if (!pass) pass = 'x';
|
|
|
|
if (!pass) pass = 'x';
|
|
|
|
let pass_split = pass.split(":");
|
|
|
|
let pass_split = pass.split(":");
|
|
|
|
|
|
|
|
this.oldVersion = false;
|
|
|
|
this.error = "";
|
|
|
|
this.error = "";
|
|
|
|
this.identifier = pass_split[0];
|
|
|
|
this.identifier = pass_split[0];
|
|
|
|
this.proxy = false;
|
|
|
|
this.proxy = false;
|
|
|
@ -589,6 +591,11 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function processShare(miner, job, blockTemplate, params) {
|
|
|
|
function processShare(miner, job, blockTemplate, params) {
|
|
|
|
|
|
|
|
if (miner.oldVersion) {
|
|
|
|
|
|
|
|
sendReply("Incorrect hashing protocol in use. Please upgrade/fix your miner");
|
|
|
|
|
|
|
|
process.send({type: "invalidShare"});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
let nonce = params.nonce;
|
|
|
|
let nonce = params.nonce;
|
|
|
|
let resultHash = params.result;
|
|
|
|
let resultHash = params.result;
|
|
|
|
let template = new Buffer(blockTemplate.buffer.length);
|
|
|
|
let template = new Buffer(blockTemplate.buffer.length);
|
|
|
@ -618,6 +625,22 @@ function processShare(miner, job, blockTemplate, params) {
|
|
|
|
shareType = false;
|
|
|
|
shareType = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hash.toString('hex') !== resultHash) {
|
|
|
|
if (hash.toString('hex') !== resultHash) {
|
|
|
|
|
|
|
|
if (job.height >= 1546000 && coinFuncs.isxmr) {
|
|
|
|
|
|
|
|
hash = multiHashing.cryptonight(convertedBlob, 0);
|
|
|
|
|
|
|
|
if (hash.toString("hex") === resultHash) {
|
|
|
|
|
|
|
|
console.error(threadName + "Bad hashing algo (CN/0) from miner " + miner.logString);
|
|
|
|
|
|
|
|
process.send({type: "invalidShare"});
|
|
|
|
|
|
|
|
miner.oldVersion = true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
hash = multiHashing.cryptonight(convertedBlob, 1);
|
|
|
|
|
|
|
|
if (hash.toString("hex") === resultHash) {
|
|
|
|
|
|
|
|
console.error(threadName + "Bad hashing algo (CN/1) from miner " + miner.logString);
|
|
|
|
|
|
|
|
process.send({type: "invalidShare"});
|
|
|
|
|
|
|
|
miner.oldVersion = true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
console.error(threadName + "Bad share from miner " + miner.logString);
|
|
|
|
console.error(threadName + "Bad share from miner " + miner.logString);
|
|
|
|
process.send({type: 'invalidShare'});
|
|
|
|
process.send({type: 'invalidShare'});
|
|
|
|
if (miner.incremented === false) {
|
|
|
|
if (miner.incremented === false) {
|
|
|
|