From cd61e7c903142f2b1ef7bbb697bef00fba34cec7 Mon Sep 17 00:00:00 2001 From: Simon Wicky Date: Tue, 20 May 2025 16:08:05 +0200 Subject: [PATCH] add active_only option for semi-skimmed node build_response --- nym-api/src/nym_nodes/handlers/unstable/semi_skimmed.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nym-api/src/nym_nodes/handlers/unstable/semi_skimmed.rs b/nym-api/src/nym_nodes/handlers/unstable/semi_skimmed.rs index 8b74396411..572ba25a19 100644 --- a/nym-api/src/nym_nodes/handlers/unstable/semi_skimmed.rs +++ b/nym-api/src/nym_nodes/handlers/unstable/semi_skimmed.rs @@ -28,6 +28,7 @@ fn build_nym_nodes_response<'a, NI>( rewarded_set: &CachedEpochRewardedSet, nym_nodes_subset: NI, annotations: &HashMap, + active_only: bool, ) -> Vec where NI: Iterator + 'a, @@ -38,6 +39,11 @@ where let role: NodeRole = rewarded_set.role(node_id).into(); + // if the role is inactive, see if our filter allows it + if active_only && role.is_inactive() { + continue; + } + // honestly, not sure under what exact circumstances this value could be missing, // but in that case just use 0 performance let annotation = annotations.get(&node_id).copied().unwrap_or_default(); @@ -109,7 +115,7 @@ pub(super) async fn nodes_expanded( let legacy_mixnodes = state.legacy_mixnode_annotations().await?; let legacy_gateways = state.legacy_gateways_annotations().await?; - let mut nodes = build_nym_nodes_response(&rewarded_set, all_nym_nodes, &annotations); + let mut nodes = build_nym_nodes_response(&rewarded_set, all_nym_nodes, &annotations, false); // add legacy gateways to the response add_legacy(&mut nodes, &rewarded_set, &describe_cache, &legacy_gateways);