Skip to content

Commit

Permalink
fix(config): test trusted gateways urls
Browse files Browse the repository at this point in the history
  • Loading branch information
karlprieb committed Nov 27, 2024
1 parent 1560393 commit e6ae5b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ export const TRUSTED_GATEWAYS_URLS = JSON.parse(
),
) as Record<string, number>;

// Validate URLs and weights
Object.entries(TRUSTED_GATEWAYS_URLS).forEach(([url, weight]) => {
try {
new URL(url);
} catch (error) {
throw new Error(`Invalid URL in TRUSTED_GATEWAY_URLS: ${url}`);
}
if (typeof weight !== 'number' || weight <= 0) {
throw new Error(
`Invalid weight in TRUSTED_GATEWAY_URLS for ${url}: ${weight}`,
);
}
});

// Trusted chunk POST URLs (for posting chunks received at /chunk)
export const CHUNK_POST_URLS = env
.varOrDefault('CHUNK_POST_URLS', `${TRUSTED_NODE_URL}/chunk`)
Expand Down
2 changes: 0 additions & 2 deletions src/data/gateways-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ export class GatewaysDataSource implements ContiguousDataSource {
priority,
error: error.message,
});

continue;
}
}

Expand Down

0 comments on commit e6ae5b7

Please sign in to comment.