From 5e2f8a40afbc0bc7ab0430e2466e14cccc6b9a7a Mon Sep 17 00:00:00 2001 From: aglkm <39521015+aglkm@users.noreply.github.com> Date: Sat, 14 Mar 2026 22:39:20 +0300 Subject: [PATCH] fixed duplicates --- src/requests.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/requests.rs b/src/requests.rs index 325ca1b..6fb8b63 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -130,6 +130,7 @@ pub async fn get_mempool(dashboard: Arc>) -> Result<(), anyhow: // Collecting: inbound, outbound, user_agent. pub async fn get_connected_peers(dashboard: Arc>, statistics: Arc>) -> Result<(), anyhow::Error> { let mut peers = HashMap::new(); + let mut addrs = Vec::new(); let mut inbound = 0; let mut outbound = 0; @@ -145,7 +146,10 @@ pub async fn get_connected_peers(dashboard: Arc>, statistics: A outbound += 1; } // Collecting user_agent nodes stats - *peers.entry(peer["user_agent"].to_string()).or_insert(0) += 1; + if !addrs.contains(&peer["addr"].to_string()) { + *peers.entry(peer["user_agent"].to_string()).or_insert(0) += 1; + addrs.push(peer["addr"].to_string()); + } } } @@ -157,7 +161,10 @@ pub async fn get_connected_peers(dashboard: Arc>, statistics: A if resp != Value::Null { for peer in resp["result"]["Ok"].as_array().unwrap() { // Collecting user_agent nodes stats - *peers.entry(peer["user_agent"].to_string()).or_insert(0) += 1; + if !addrs.contains(&peer["addr"].to_string()) { + *peers.entry(peer["user_agent"].to_string()).or_insert(0) += 1; + addrs.push(peer["addr"].to_string()); + } } } },