Skip to content

Commit

Permalink
always set bid data
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jun 6, 2024
1 parent 8bfc8e4 commit 5494ddc
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/Job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default class Job implements _Job {
const expectedOutputFormat: string =
Utils.getTagVars(event, ["output"])[0][0] || "application/json";

const bidData = Utils.getTagVars(event, ["bid"])[0];
const bidData = Utils.getTagVars(event, ["bid"])[0]||[];

const description: string =
Utils.getTagVars(event, ["about"])[0][0] ||
Expand Down Expand Up @@ -236,16 +236,15 @@ export default class Job implements _Job {
}

// calculate bid for each worker
if (bidData) {
const bid = bidData[0];
const bidCurrency = bidData[1] || Utils.getTagVars(event, ["t"])[0][0] || "bitcoin";
const bidProto = bidData[2] || "lightning";
this.bid = {
amount: Number(bid) / minWorkers,
currency: bidCurrency,
protocol: bidProto,
};
}
const bid = bidData[0] || 0;
const bidCurrency = bidData[1] || Utils.getTagVars(event, ["t"])[0][0] || "bitcoin";
const bidProto = bidData[2] || "lightning";
this.bid = {
amount: Number(bid) / minWorkers,
currency: bidCurrency,
protocol: bidProto,
};

} else if (event.kind == 7000 || (event.kind >= 6000 && event.kind <= 6999)) {
const e: Array<string> = Utils.getTagVars(event, ["e"])[0];
const jobId: string = e[0];
Expand Down

0 comments on commit 5494ddc

Please sign in to comment.