Clean up
This commit is contained in:
@@ -35,8 +35,6 @@ export default async function NymNode({
|
||||
const observatoryNymNodes: IObservatoryNode[] =
|
||||
await observatoryResponse.json();
|
||||
|
||||
console.log("observatoryNymNodes :>> ", observatoryNymNodes);
|
||||
|
||||
if (!observatoryNymNodes) {
|
||||
return null;
|
||||
}
|
||||
@@ -45,8 +43,6 @@ export default async function NymNode({
|
||||
(node) => node.node_id === id,
|
||||
);
|
||||
|
||||
console.log("observatorynNymNode :>> ", observatoryNymNode);
|
||||
|
||||
if (!observatoryNymNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,10 @@ const CountryFlag = ({ countryCode, countryName }: ICountryFlag) => {
|
||||
return (
|
||||
<Stack direction="row" gap={1}>
|
||||
<Flag code={countryCode} width="19" />
|
||||
{countryName && (
|
||||
<Typography variant="subtitle2" sx={{ color: "pine.950" }}>
|
||||
{countryName}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<Typography variant="subtitle2" sx={{ color: "pine.950" }}>
|
||||
{countryName}
|
||||
</Typography>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -50,7 +50,6 @@ export const NodeProfileCard = (props: INodeProfileCardProps) => {
|
||||
"Delegation from Nym Explorer V2",
|
||||
uNymFunds,
|
||||
);
|
||||
console.log({ tx });
|
||||
setSelectedNodeForStaking(undefined);
|
||||
setInfoModalProps({
|
||||
open: true,
|
||||
|
||||
@@ -10,15 +10,9 @@ interface INodeRewardsCardProps {
|
||||
export const NodeRewardsCard = (props: INodeRewardsCardProps) => {
|
||||
const { rewardDetails } = props;
|
||||
|
||||
// const totalRewards = Number(rewardDetails.total_unit_reward) / 1000000;
|
||||
// const totalRewardsFormated = `${totalRewards} NYM`;
|
||||
|
||||
const operatorRewards = Number(rewardDetails.operator) / 1000000;
|
||||
const operatorRewardsFormated = `${operatorRewards} NYM`;
|
||||
|
||||
// const stakerRewards = Number(rewardDetails.delegates) / 1000000;
|
||||
// const stakerRewardsFormated = `${stakerRewards} NYM`;
|
||||
|
||||
const profitMarginPercent =
|
||||
Number(rewardDetails.cost_params.profit_margin_percent) * 100;
|
||||
|
||||
|
||||
@@ -38,23 +38,22 @@ function getNodeRoles(
|
||||
}
|
||||
|
||||
function calculateQualityOfServiceStars(quality: number): number {
|
||||
if (quality < 0.3) {
|
||||
return 1;
|
||||
switch (true) {
|
||||
case quality < 0.3:
|
||||
return 1;
|
||||
case quality < 0.5:
|
||||
return 2;
|
||||
case quality < 0.7:
|
||||
return 3;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
if (quality < 0.5) {
|
||||
return 2;
|
||||
}
|
||||
if (quality < 0.7) {
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
function calculateConfigScoreStars(probeResult: LastProbeResult): number {
|
||||
const { as_entry, as_exit } = probeResult.outcome;
|
||||
|
||||
if (as_entry && as_exit) {
|
||||
// Combine all true/false values for as_entry and as_exit
|
||||
const allResults = [
|
||||
as_entry.can_connect,
|
||||
as_entry.can_route,
|
||||
@@ -67,34 +66,32 @@ function calculateConfigScoreStars(probeResult: LastProbeResult): number {
|
||||
|
||||
const combinedScore = allResults.filter(Boolean).length;
|
||||
|
||||
if (combinedScore === 7) {
|
||||
return 4; // 4 stars if all 7 are true
|
||||
switch (combinedScore) {
|
||||
case 7:
|
||||
return 4;
|
||||
case 6:
|
||||
return 3;
|
||||
case 5:
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
if (combinedScore === 6) {
|
||||
return 3; // 3 stars if 6 are true
|
||||
}
|
||||
if (combinedScore === 5) {
|
||||
return 2; // 2 stars if 5 are true
|
||||
}
|
||||
return 1; // 1 star if less than 5 are true
|
||||
}
|
||||
|
||||
// Check if only as_entry exists and calculate stars
|
||||
if (as_entry) {
|
||||
const { can_connect, can_route } = as_entry;
|
||||
|
||||
const entryScore = [can_connect, can_route].filter(Boolean).length;
|
||||
|
||||
if (entryScore === 2) {
|
||||
return 4; // 4 stars if both are true
|
||||
switch (entryScore) {
|
||||
case 2:
|
||||
return 4;
|
||||
case 1:
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
if (entryScore === 1) {
|
||||
return 2; // 2 stars if one is true
|
||||
}
|
||||
return 1; // 1 star if both are false
|
||||
}
|
||||
|
||||
// Check if only as_exit exists and calculate stars
|
||||
if (as_exit) {
|
||||
const {
|
||||
can_connect,
|
||||
@@ -112,20 +109,19 @@ function calculateConfigScoreStars(probeResult: LastProbeResult): number {
|
||||
can_route_ip_v6,
|
||||
].filter(Boolean).length;
|
||||
|
||||
if (exitScore === 5) {
|
||||
return 4; // 4 stars if all 5 are true
|
||||
switch (exitScore) {
|
||||
case 5:
|
||||
return 4;
|
||||
case 4:
|
||||
return 3;
|
||||
case 3:
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
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
|
||||
return 0; // Default case if neither as_entry nor as_exit is present
|
||||
}
|
||||
|
||||
function calculateWireguardPerformance(probeResult: LastProbeResult): number {
|
||||
@@ -135,7 +131,6 @@ function calculateWireguardPerformance(probeResult: LastProbeResult): number {
|
||||
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 +
|
||||
@@ -143,42 +138,32 @@ function calculateWireguardPerformance(probeResult: LastProbeResult): number {
|
||||
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;
|
||||
}
|
||||
switch (true) {
|
||||
case 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;
|
||||
}
|
||||
case 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;
|
||||
}
|
||||
case 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;
|
||||
}
|
||||
case as_exit && (!as_exit.can_route_ip_v4 || !as_exit.can_route_ip_v6):
|
||||
return 1;
|
||||
|
||||
// Default case: No matching conditions
|
||||
return 1;
|
||||
default:
|
||||
return 1; // Default case
|
||||
}
|
||||
}
|
||||
|
||||
export const QualityIndicatorsCard = (props: IQualityIndicatorsCardProps) => {
|
||||
|
||||
Reference in New Issue
Block a user