From f75977ed93fa619de1b1928a72babaeaab89bf66 Mon Sep 17 00:00:00 2001 From: lbqds Date: Mon, 26 Aug 2024 07:52:56 +0800 Subject: [PATCH] Send one job to miners --- lib/jobManager.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jobManager.js b/lib/jobManager.js index e58e354..f8514f1 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -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(){ @@ -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); };