-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yana/frontend fixes #5341
Merged
Merged
Yana/frontend fixes #5341
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fmtabbara
reviewed
Jan 13, 2025
fmtabbara
reviewed
Jan 13, 2025
fmtabbara
reviewed
Jan 13, 2025
fmtabbara
reviewed
Jan 13, 2025
fmtabbara
reviewed
Jan 13, 2025
explorer-nextjs/src/components/nymNodePageComponents/NodeProfileCard.tsx
Outdated
Show resolved
Hide resolved
fmtabbara
reviewed
Jan 13, 2025
explorer-nextjs/src/components/nymNodePageComponents/NodeRewardsCard.tsx
Outdated
Show resolved
Hide resolved
fmtabbara
reviewed
Jan 13, 2025
explorer-nextjs/src/components/nymNodePageComponents/NodeRewardsCard.tsx
Outdated
Show resolved
Hide resolved
fmtabbara
reviewed
Jan 13, 2025
Comment on lines
56
to
182
const entryScore = [can_connect, can_route].filter(Boolean).length; | ||
|
||
if (!nodeDescription) { | ||
return null; | ||
if (entryScore === 2) { | ||
return 4; // 4 stars if both are true | ||
} | ||
if (entryScore === 1) { | ||
return 2; // 2 stars if one is true | ||
} | ||
return 1; // 1 star if both are false | ||
} | ||
|
||
const nodeRoles = getNodeRoles(nodeDescription.declared_role); | ||
// Check if only as_exit exists and calculate stars | ||
if (as_exit) { | ||
const { | ||
can_connect, | ||
can_route_ip_external_v4, | ||
can_route_ip_external_v6, | ||
can_route_ip_v4, | ||
can_route_ip_v6, | ||
} = as_exit; | ||
|
||
const exitScore = [ | ||
can_connect, | ||
can_route_ip_external_v4, | ||
can_route_ip_external_v6, | ||
can_route_ip_v4, | ||
can_route_ip_v6, | ||
].filter(Boolean).length; | ||
|
||
if (exitScore === 5) { | ||
return 4; // 4 stars if all 5 are true | ||
} | ||
if (exitScore === 4) { | ||
return 3; // 3 stars if 4 true, 1 false | ||
} | ||
if (exitScore === 3) { | ||
return 2; // 2 stars if 3 true, 2 false | ||
} | ||
return 1; // 1 star if 2 true or less | ||
} | ||
|
||
// Default case if neither as_entry nor as_exit is present | ||
return 0; // No stars | ||
} | ||
|
||
function calculateWireguardPerformance(probeResult: LastProbeResult): number { | ||
const { wg, as_exit } = probeResult.outcome; | ||
|
||
if (!wg) { | ||
return 1; // Default to 1 star if Wireguard information is missing | ||
} | ||
|
||
// Calculate average ping performance | ||
const pingPerformance = | ||
(wg.ping_hosts_performance_v4 + | ||
wg.ping_hosts_performance_v6 + | ||
wg.ping_ips_performance_v4 + | ||
wg.ping_ips_performance_v6) / | ||
4; | ||
|
||
// 4 stars: Can register, complete handshakes, resolve DNS, and ping performance > 0.75 | ||
if ( | ||
wg.can_register && | ||
wg.can_handshake_v4 && | ||
wg.can_handshake_v6 && | ||
wg.can_resolve_dns_v4 && | ||
wg.can_resolve_dns_v6 && | ||
pingPerformance > 0.75 | ||
) { | ||
return 4; | ||
} | ||
|
||
// 3 stars: Can register, complete handshakes, resolve DNS, but ping performance <= 0.75 | ||
if ( | ||
wg.can_register && | ||
wg.can_handshake_v4 && | ||
wg.can_handshake_v6 && | ||
wg.can_resolve_dns_v4 && | ||
wg.can_resolve_dns_v6 && | ||
pingPerformance <= 0.75 | ||
) { | ||
return 3; | ||
} | ||
|
||
// 2 stars: Can register, but handshake v4 or v6 is false | ||
if (wg.can_register && (!wg.can_handshake_v4 || !wg.can_handshake_v6)) { | ||
return 2; | ||
} | ||
|
||
// 1 star: If "as_exit" exists but cannot route ipv4 or ipv6 | ||
if (as_exit && (!as_exit.can_route_ip_v4 || !as_exit.can_route_ip_v6)) { | ||
return 1; | ||
} | ||
|
||
// Default case: No matching conditions | ||
return 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think switch statements would make this a bit easier to follow
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change is