Guard pool login before first block template
Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 47s

This commit is contained in:
Codex Bot
2026-03-21 20:33:00 +01:00
parent d8a3c32ff5
commit 38a8187c07

View File

@@ -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) {