Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nym-node-status-api/nym-node-status-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "nym-node-status-api"
version = "4.0.5"
version = "4.0.6"
authors.workspace = true
repository.workspace = true
homepage.workspace = true
Expand Down
31 changes: 29 additions & 2 deletions nym-node-status-api/nym-node-status-api/src/http/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub struct Location {
#[derive(Debug, Clone, Deserialize, Serialize, ToSchema, EnumString)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
#[derive(PartialEq)]
pub enum ScoreValue {
Offline,
Low,
Expand All @@ -89,6 +90,7 @@ pub enum ScoreValue {
pub struct DVpnGatewayPerformance {
last_updated_utc: String,
score: ScoreValue,
mixnet_score: ScoreValue,
load: ScoreValue,
uptime_percentage_last_24_hours: f32,
}
Expand Down Expand Up @@ -293,10 +295,20 @@ impl DVpnGateway {
});

tracing::info!("🌈 gateway probe parsed: {:?}", parsed);
let mixnet_score = calculate_mixnet_score(&gateway);
let score = calculate_score(&gateway, &parsed);
let mut load = calculate_load(&parsed);

// clamp the load value to offline, when the score is offline
if score == ScoreValue::Offline {
load = ScoreValue::Offline;
}

let performance_v2 = DVpnGatewayPerformance {
last_updated_utc: last_updated_utc.to_string(),
load: calculate_load(&parsed),
score: calculate_score(&gateway, &parsed),
load,
score,
mixnet_score,

// the network monitor's measure is a good proxy for node uptime, it can be improved in the future
uptime_percentage_last_24_hours: network_monitor_performance_mixnet_mode,
Expand Down Expand Up @@ -353,6 +365,21 @@ impl DVpnGateway {
}
}

/// calculates the gateway probe score for mixnet mode
fn calculate_mixnet_score(gateway: &Gateway) -> ScoreValue {
let mixnet_performance = gateway.performance as f64 / 100.0;

if mixnet_performance > 0.8 {
ScoreValue::High
} else if mixnet_performance > 0.6 {
ScoreValue::Medium
} else if mixnet_performance > 0.1 {
ScoreValue::Low
} else {
ScoreValue::Offline
}
}

/// calculates a visual score for the gateway
fn calculate_score(gateway: &Gateway, probe_outcome: &LastProbeResult) -> ScoreValue {
let mixnet_performance = gateway.performance as f64 / 100.0;
Expand Down
Loading