diff --git a/massa-api/src/public.rs b/massa-api/src/public.rs index 6b9ffc241d2..8d40ac9511d 100644 --- a/massa-api/src/public.rs +++ b/massa-api/src/public.rs @@ -53,6 +53,7 @@ use massa_pool_exports::PoolController; use massa_signature::KeyPair; use massa_storage::Storage; use massa_time::MassaTime; +use std::collections::BTreeMap; use std::net::{IpAddr, SocketAddr}; impl API { @@ -359,21 +360,22 @@ impl MassaRpcServer for API { Err(e) => return Err(ApiError::from(e).into()), }; + let connected_nodes = peers + .peers + .iter() + .flat_map(|(ip, peer)| { + peer.active_nodes + .iter() + .map(move |(id, is_outgoing)| (*id, (*ip, *is_outgoing))) + }) + .collect::>(); + Ok(NodeStatus { node_id, node_ip: network_config.routable_ip, version, current_time: now, - connected_nodes: peers - .peers - .iter() - .sorted() - .flat_map(|(ip, peer)| { - peer.active_nodes - .iter() - .map(move |(id, is_outgoing)| (*id, (*ip, *is_outgoing))) - }) - .collect(), + connected_nodes, last_slot, next_slot, execution_stats, diff --git a/massa-models/src/api.rs b/massa-models/src/api.rs index 452ab4be06c..d3284ade9b4 100644 --- a/massa-models/src/api.rs +++ b/massa-models/src/api.rs @@ -13,7 +13,7 @@ use crate::{ use massa_signature::{PublicKey, Signature}; use massa_time::MassaTime; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; +use std::collections::BTreeMap; use std::net::IpAddr; /// operation input @@ -41,7 +41,7 @@ pub struct NodeStatus { /// current cycle pub current_cycle: u64, /// connected nodes (node id, ip address, true if the connection is outgoing, false if incoming) - pub connected_nodes: HashMap, + pub connected_nodes: BTreeMap, /// latest slot, none if now is before genesis timestamp pub last_slot: Option, /// next slot diff --git a/massa-network-exports/src/peers.rs b/massa-network-exports/src/peers.rs index 739f0f661bb..cf21fb42607 100644 --- a/massa-network-exports/src/peers.rs +++ b/massa-network-exports/src/peers.rs @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize}; use std::ops::Bound::Included; use std::{collections::HashMap, net::IpAddr}; /// Associate a peer info with nodes -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Peer { /// peer info pub peer_info: PeerInfo, @@ -176,7 +176,7 @@ impl Default for PeerType { } /// All information concerning a peer is here -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Debug)] +#[derive(Clone, Copy, Serialize, Deserialize, Debug)] pub struct PeerInfo { /// Peer ip address. pub ip: IpAddr,