Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send one job to miners #67

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading