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 () {
|
||||
let blockTemplate = currentBlockTemplate[0];
|
||||
if (!blockTemplate) {
|
||||
return null;
|
||||
}
|
||||
let newJob = {
|
||||
id: utils.uid(),
|
||||
height: blockTemplate.height,
|
||||
@@ -625,10 +628,16 @@ function handleMinerMethod (method, params, ip, portData, sendReply, pushMessage
|
||||
let minerId = utils.uid();
|
||||
miner = new Miner(rewardType, minerId, login, pass, ip, port, params.agent, difficulty, noRetarget, pushMessage);
|
||||
connectedMiners[minerId] = miner;
|
||||
let minerJob = miner.getJob();
|
||||
if (!minerJob) {
|
||||
delete connectedMiners[minerId];
|
||||
sendReply('No active block template yet');
|
||||
return;
|
||||
}
|
||||
|
||||
sendReply(null, {
|
||||
id: minerId,
|
||||
job: miner.getJob(),
|
||||
job: minerJob,
|
||||
status: 'OK'
|
||||
});
|
||||
|
||||
@@ -640,7 +649,12 @@ function handleMinerMethod (method, params, ip, portData, sendReply, pushMessage
|
||||
return;
|
||||
}
|
||||
miner.heartbeat();
|
||||
sendReply(null, miner.getJob());
|
||||
let jobReply = miner.getJob();
|
||||
if (!jobReply) {
|
||||
sendReply('No active block template yet');
|
||||
return;
|
||||
}
|
||||
sendReply(null, jobReply);
|
||||
break;
|
||||
case 'submit':
|
||||
if (!miner) {
|
||||
|
||||
Reference in New Issue
Block a user