Skip to content

Commit

Permalink
Merge pull request #67 from alephium/send-one-job-to-miners
Browse files Browse the repository at this point in the history
Send one job to miners
  • Loading branch information
polarker authored Aug 26, 2024
2 parents 2982902 + f75977e commit 8748445
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/jobManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const bignum = require('bignum');
const blockTemplate = require('./blockTemplate.js');
const constants = require('./constants.js');
const util = require('./util');
const crypto = require('crypto');

//Unique job per new block template
var JobCounter = function(){
Expand Down Expand Up @@ -74,11 +75,10 @@ function JobManager(jobExpiryPeriod){

this.processJobs = function(jobs){
var now = Date.now();
var miningJobs = jobs.map(job => {
var jobId = jobCounter.next();
job.jobId = jobId;
return new blockTemplate(job, now);
})
var jobIndex = crypto.randomInt(0, jobs.length)
var job = jobs[jobIndex]
job.jobId = jobCounter.next()
var miningJobs = [new blockTemplate(job, now)]
_this.validJobs.addJobs(miningJobs, now);
_this.emit('newJobs', miningJobs);
};
Expand Down

0 comments on commit 8748445

Please sign in to comment.