From 9c1b074f87f1a55d59b706d30238cb3ff767dc08 Mon Sep 17 00:00:00 2001 From: Mark Sinclair <14054343+mmsinclair@users.noreply.github.com> Date: Fri, 10 Oct 2025 14:47:36 +0100 Subject: [PATCH] NS API: use new probe download filesize and milliseconds field (#6097) * use milliseconds field * change score thresholds * bump to version 4.0.8 * NS API: adjust score categories (#6103) * testing scores * test version * Update Cargo.toml --------- Co-authored-by: Mark Sinclair Co-authored-by: benedetta davico <46782255+benedettadavico@users.noreply.github.com> --- Cargo.lock | 2 +- .../nym-node-status-api/Cargo.toml | 2 +- .../nym-node-status-api/src/http/models.rs | 20 +++++++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eda78ac57e..468e47a6dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6598,7 +6598,7 @@ dependencies = [ [[package]] name = "nym-node-status-api" -version = "4.0.7" +version = "4.0.8" dependencies = [ "ammonia", "anyhow", diff --git a/nym-node-status-api/nym-node-status-api/Cargo.toml b/nym-node-status-api/nym-node-status-api/Cargo.toml index 09f0889ba3..8e36110ad1 100644 --- a/nym-node-status-api/nym-node-status-api/Cargo.toml +++ b/nym-node-status-api/nym-node-status-api/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nym-node-status-api" -version = "4.0.7" +version = "4.0.8" authors.workspace = true repository.workspace = true homepage.workspace = true diff --git a/nym-node-status-api/nym-node-status-api/src/http/models.rs b/nym-node-status-api/nym-node-status-api/src/http/models.rs index 817f3150ac..f41e3731fe 100644 --- a/nym-node-status-api/nym-node-status-api/src/http/models.rs +++ b/nym-node-status-api/nym-node-status-api/src/http/models.rs @@ -395,20 +395,24 @@ fn calculate_score(gateway: &Gateway, probe_outcome: &LastProbeResult) -> ScoreV .map(|p| { let ping_ips_performance = p.ping_ips_performance_v4 as f64; - let duration = p.download_duration_sec_v4 as f64; + let duration_sec = + p.download_duration_milliseconds_v4 + .unwrap_or_else(|| p.download_duration_sec_v4 * 1000) as f64 + / 1000f64; // get the file size downloaded in bytes and convert to MB, or default to 1MB - let file_size_mb = - p.downloaded_file_size_bytes_v4.unwrap_or(1048576) as f64 / 1024f64 / 1024f64; - let speed_mbps = file_size_mb / duration; + let file_size_mb = p.downloaded_file_size_bytes_v4.unwrap_or_else(|| 1048576) as f64 + / 1024f64 + / 1024f64; + let speed_mbps = file_size_mb / duration_sec; - let file_download_score = if speed_mbps > 100.0 { + let file_download_score = if speed_mbps > 5.0 { 1.0 - } else if speed_mbps > 50.0 { + } else if speed_mbps > 2.0 { 0.75 - } else if speed_mbps > 20.0 { + } else if speed_mbps > 1.0 { 0.5 - } else if speed_mbps > 10.0 { + } else if speed_mbps > 0.5 { 0.25 } else { 0.1