Skip to content

Commit

Permalink
Transactions from node 0 are stopping it from finding the 1-2-3-1 tri…
Browse files Browse the repository at this point in the history
…angle
  • Loading branch information
michielbdejong committed Oct 25, 2024
1 parent f1bdded commit 05051f1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion __tests__/SingleThread.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('SingleThread', () => {
// writeFileSync(`./__tests__/fixtures/sarafu-300.solution`, solution);
// }
expect(solution).toEqual(read);
expect(cummNumProbes).toEqual(3);
expect(cummNumProbes).toEqual(22);

expect(await threadRunner.solutionIsComplete()).toEqual(true);
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/fixtures/sarafu-300.solution
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(2-0:0) [2 1 3 2]
(2-0:3) [2 1 3 2]
15 changes: 1 addition & 14 deletions src/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,10 @@ export class Worker {
await readSarafuCsv(filename, (from: string, to: string, amount: number) => {
if (parseInt(from) % this.numWorkers === this.workerNo) {
if (parseInt(from) % this.numWorkers === this.workerNo) {
if (['1','2','3'].indexOf(from) === -1) {
if (parseInt(from) === 0) {
this.debug(`skipping transaction from ${from}`);
return;
}
if (['1','2','3'].indexOf(to) === -1) {
this.debug(`skipping transaction to ${to}`);
return;
}
this.debug(`not skipping transaction from ${from} to ${to}`);
this.addWeight(from, to, amount);
}
Expand All @@ -236,15 +232,6 @@ export class Worker {
const [ from, to, amountStr ] = cells;
const amount = parseFloat(amountStr);
if (parseInt(from) % this.numWorkers === this.workerNo) {
if (['1','2','3'].indexOf(from) === -1) {
this.debug(`skipping transaction from ${from}`);
return;
}
if (['1','2','3'].indexOf(to) === -1) {
this.debug(`skipping transaction to ${to}`);
return;
}
this.debug(`not skipping transaction from ${from} to ${to}`);
this.addWeight(from, to, amount);
}
});
Expand Down

0 comments on commit 05051f1

Please sign in to comment.