Guard pool login before first block template
Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 47s
Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 47s
This commit is contained in:
18
lib/pool.js
18
lib/pool.js
@@ -418,6 +418,9 @@ Miner.prototype = {
|
|||||||
},
|
},
|
||||||
getJob: function () {
|
getJob: function () {
|
||||||
let blockTemplate = currentBlockTemplate[0];
|
let blockTemplate = currentBlockTemplate[0];
|
||||||
|
if (!blockTemplate) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let newJob = {
|
let newJob = {
|
||||||
id: utils.uid(),
|
id: utils.uid(),
|
||||||
height: blockTemplate.height,
|
height: blockTemplate.height,
|
||||||
@@ -625,10 +628,16 @@ function handleMinerMethod (method, params, ip, portData, sendReply, pushMessage
|
|||||||
let minerId = utils.uid();
|
let minerId = utils.uid();
|
||||||
miner = new Miner(rewardType, minerId, login, pass, ip, port, params.agent, difficulty, noRetarget, pushMessage);
|
miner = new Miner(rewardType, minerId, login, pass, ip, port, params.agent, difficulty, noRetarget, pushMessage);
|
||||||
connectedMiners[minerId] = miner;
|
connectedMiners[minerId] = miner;
|
||||||
|
let minerJob = miner.getJob();
|
||||||
|
if (!minerJob) {
|
||||||
|
delete connectedMiners[minerId];
|
||||||
|
sendReply('No active block template yet');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sendReply(null, {
|
sendReply(null, {
|
||||||
id: minerId,
|
id: minerId,
|
||||||
job: miner.getJob(),
|
job: minerJob,
|
||||||
status: 'OK'
|
status: 'OK'
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -640,7 +649,12 @@ function handleMinerMethod (method, params, ip, portData, sendReply, pushMessage
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
miner.heartbeat();
|
miner.heartbeat();
|
||||||
sendReply(null, miner.getJob());
|
let jobReply = miner.getJob();
|
||||||
|
if (!jobReply) {
|
||||||
|
sendReply('No active block template yet');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendReply(null, jobReply);
|
||||||
break;
|
break;
|
||||||
case 'submit':
|
case 'submit':
|
||||||
if (!miner) {
|
if (!miner) {
|
||||||
|
|||||||
Reference in New Issue
Block a user