Skip to content

Commit

Permalink
Merge pull request #2344 from threefoldtech/development_fix_mycelium
Browse files Browse the repository at this point in the history
Fix mycelium validation for the peers
  • Loading branch information
amiraabouhadid authored Mar 5, 2024
2 parents 95095f9 + 98aac91 commit 2d8bdd4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/grid_client/src/zos/znet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { Expose, Type } from "class-transformer";
import { ArrayNotEmpty, IsDefined, IsInt, IsNotEmpty, IsString, Length, ValidateNested } from "class-validator";
import {
ArrayNotEmpty,
IsDefined,
IsInt,
IsNotEmpty,
IsOptional,
IsString,
Length,
ValidateNested,
} from "class-validator";

import { WorkloadData } from "./workload_base";

Expand All @@ -24,7 +33,7 @@ class Peer {

class Mycelium {
@Expose() @IsString() @IsNotEmpty() hex_key: string;
@Expose() @IsString({ each: true }) peers: string[];
@Expose() @IsOptional() @IsString({ each: true }) peers?: string[];
}

class Znet extends WorkloadData {
Expand All @@ -46,7 +55,7 @@ class Znet extends WorkloadData {
out += this.peers[i].challenge();
}
out += this.mycelium?.hex_key || "";
for (let i = 0; i < this.mycelium?.peers.length; i++) {
for (let i = 0; i < this.mycelium?.peers?.length; i++) {
out += this.mycelium?.peers[i] || "";
}
return out;
Expand Down

0 comments on commit 2d8bdd4

Please sign in to comment.