|
|
|
@ -215,9 +215,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer
|
|
|
|
|
let pass_split = pass.split(":");
|
|
|
|
|
this.error = "";
|
|
|
|
|
this.identifier = pass_split[0];
|
|
|
|
|
this.proxy = false;
|
|
|
|
|
if (agent && agent.includes('MinerGate')){
|
|
|
|
|
this.identifier = "MinerGate";
|
|
|
|
|
}
|
|
|
|
|
if (agent && agent.includes('xmr-node-proxy')){
|
|
|
|
|
this.proxy = true;
|
|
|
|
|
}
|
|
|
|
|
this.paymentID = null;
|
|
|
|
|
this.valid_miner = true;
|
|
|
|
|
this.port = port;
|
|
|
|
@ -463,27 +467,52 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer
|
|
|
|
|
return this.cachedJob;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let blob = activeBlockTemplate.nextBlob();
|
|
|
|
|
let target = this.getTargetHex();
|
|
|
|
|
this.lastBlockHeight = activeBlockTemplate.height;
|
|
|
|
|
if (!this.proxy){
|
|
|
|
|
let blob = activeBlockTemplate.nextBlob();
|
|
|
|
|
let target = this.getTargetHex();
|
|
|
|
|
this.lastBlockHeight = activeBlockTemplate.height;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let newJob = {
|
|
|
|
|
id: crypto.pseudoRandomBytes(21).toString('base64'),
|
|
|
|
|
extraNonce: activeBlockTemplate.extraNonce,
|
|
|
|
|
height: activeBlockTemplate.height,
|
|
|
|
|
difficulty: this.difficulty,
|
|
|
|
|
diffHex: this.diffHex,
|
|
|
|
|
submissions: []
|
|
|
|
|
};
|
|
|
|
|
let newJob = {
|
|
|
|
|
id: crypto.pseudoRandomBytes(21).toString('base64'),
|
|
|
|
|
extraNonce: activeBlockTemplate.extraNonce,
|
|
|
|
|
height: activeBlockTemplate.height,
|
|
|
|
|
difficulty: this.difficulty,
|
|
|
|
|
diffHex: this.diffHex,
|
|
|
|
|
submissions: []
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.validJobs.enq(newJob);
|
|
|
|
|
this.cachedJob = {
|
|
|
|
|
blob: blob,
|
|
|
|
|
job_id: newJob.id,
|
|
|
|
|
target: target,
|
|
|
|
|
id: this.id
|
|
|
|
|
};
|
|
|
|
|
this.validJobs.enq(newJob);
|
|
|
|
|
this.cachedJob = {
|
|
|
|
|
blob: blob,
|
|
|
|
|
job_id: newJob.id,
|
|
|
|
|
target: target,
|
|
|
|
|
id: this.id
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
let blob = activeBlockTemplate.nextBlobWithChildNonce();
|
|
|
|
|
this.lastBlockHeight = activeBlockTemplate.height;
|
|
|
|
|
|
|
|
|
|
let newJob = {
|
|
|
|
|
id: crypto.pseudoRandomBytes(21).toString('base64'),
|
|
|
|
|
extraNonce: activeBlockTemplate.extraNonce,
|
|
|
|
|
height: activeBlockTemplate.height,
|
|
|
|
|
difficulty: this.difficulty,
|
|
|
|
|
diffHex: this.diffHex,
|
|
|
|
|
submissions: []
|
|
|
|
|
};
|
|
|
|
|
this.validJobs.enq(newJob);
|
|
|
|
|
this.cachedJob = {
|
|
|
|
|
blocktemplate_blob: blob,
|
|
|
|
|
difficulty: activeBlockTemplate.difficulty,
|
|
|
|
|
height: activeBlockTemplate.height,
|
|
|
|
|
reserved_offset: activeBlockTemplate.reserveOffset,
|
|
|
|
|
client_nonce_offset: activeBlockTemplate.clientNonceLocation,
|
|
|
|
|
client_pool_offset: activeBlockTemplate.clientPoolLocation,
|
|
|
|
|
job_id: newJob.id,
|
|
|
|
|
id: this.id
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return this.cachedJob;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
@ -526,10 +555,19 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function processShare(miner, job, blockTemplate, nonce, resultHash) {
|
|
|
|
|
function processShare(miner, job, blockTemplate, params) {
|
|
|
|
|
let nonce = params.nonce;
|
|
|
|
|
let resultHash = params.result;
|
|
|
|
|
let template = new Buffer(blockTemplate.buffer.length);
|
|
|
|
|
blockTemplate.buffer.copy(template);
|
|
|
|
|
template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset);
|
|
|
|
|
if (!miner.proxy){
|
|
|
|
|
blockTemplate.buffer.copy(template);
|
|
|
|
|
template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset);
|
|
|
|
|
} else {
|
|
|
|
|
blockTemplate.buffer.copy(template);
|
|
|
|
|
template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset);
|
|
|
|
|
template.writeUInt32BE(params.workerNonce, blockTemplate.clientNonceLocation);
|
|
|
|
|
template.writeUInt32BE(params.poolNonce, blockTemplate.clientPoolLocation);
|
|
|
|
|
}
|
|
|
|
|
let shareBuffer = global.coinFuncs.constructNewBlob(template, new Buffer(nonce, 'hex'));
|
|
|
|
|
|
|
|
|
|
let convertedBlob;
|
|
|
|
@ -691,7 +729,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let shareAccepted = processShare(miner, job, blockTemplate, params.nonce, params.result);
|
|
|
|
|
let shareAccepted = processShare(miner, job, blockTemplate, params);
|
|
|
|
|
miner.checkBan(shareAccepted);
|
|
|
|
|
|
|
|
|
|
if (global.config.pool.trustedMiners) {
|
|
|
|
|