Skip to content

Commit

Permalink
fix(iota-network): PeerBalancer::new peers total order
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Nov 23, 2024
1 parent ab45678 commit 9bc2748
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions crates/iota-network/src/state_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,18 @@ impl PeerBalancer {
.unwrap()
.peers_on_same_chain()
// Filter out any peers who we aren't connected with.
.filter_map(|(peer_id, info)| network.peer(*peer_id).map(|peer| (peer, *info)))
.filter_map(|(peer_id, info)| {
network
.peer(*peer_id)
.map(|peer| (peer.connection_rtt(), peer, *info))
})
.collect();
peers.sort_by(|(peer_a, _), (peer_b, _)| {
peer_a.connection_rtt().cmp(&peer_b.connection_rtt())
});
peers.sort_by(|(rtt_a, _, _), (rtt_b, _, _)| rtt_a.cmp(rtt_b));
Self {
peers: peers.into(),
peers: peers
.into_iter()
.map(|(_, peer, info)| (peer, info))
.collect(),
requested_checkpoint: None,
request_type,
}
Expand Down

0 comments on commit 9bc2748

Please sign in to comment.