Skip to content

Commit d7ceda5

Browse files
committed
Refactor peer retrieval logic in get_topology function
- Updated the handling of peer data in the get_topology function to destructure PeerDump directly, improving clarity and efficiency. - Changed the collection of peers to use into_values for better performance and readability.
1 parent 5eb90ba commit d7ceda5

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

crates/api/src/route.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,15 @@ pub async fn get_topology(State(state): State<AppState>) -> Json<Vec<PeerInfoWit
6161

6262
let mut results = Vec::new();
6363
for handle in handles {
64-
if let Ok((Some(info), Some(peers))) = handle.await {
65-
let total_connected = peers.total_connected;
66-
let peers = peers.peers.into_iter().map(|(_, v)| v).collect();
64+
if let Ok((
65+
Some(info),
66+
Some(PeerDump {
67+
total_connected,
68+
peers,
69+
}),
70+
)) = handle.await
71+
{
72+
let peers = peers.into_values().collect();
6773
results.push(PeerInfoWithPeers {
6874
info,
6975
total_connected,

0 commit comments

Comments
 (0)