Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 0a7f7a0

Browse files
authored
Merge pull request #490 from threefoldtech/development_removed_negative_values
Forced value to be at least 0
2 parents c65b5bf + 3587561 commit 0a7f7a0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/types/FarmingProfile.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@ export default class FarmingProfile {
1616
public nuRequiredPerCu: number = 30
1717
) {}
1818

19+
private _max(val: number, max = 0) {
20+
val = val ?? 0;
21+
return Math.max(val, max);
22+
}
23+
1924
public get cu(): number {
2025
const { memory, cpu, ssd } = this;
2126
const x = (memory - 1) / 4;
2227
const y = cpu * 2;
2328
const z = ssd / 50;
24-
return Math.min(x, y, z);
29+
return this._max(Math.min(x, y, z));
2530
}
2631

2732
public get nu(): number {
28-
return this.cu * this.nuRequiredPerCu;
33+
return this._max(this.cu * this.nuRequiredPerCu);
2934
}
3035

3136
public get su(): number {

0 commit comments

Comments
 (0)