diff --git a/examples/chat/src/network.rs b/examples/chat/src/network.rs index e36a208..f4842e9 100644 --- a/examples/chat/src/network.rs +++ b/examples/chat/src/network.rs @@ -1,4 +1,5 @@ use std::collections::hash_map::{self, HashMap}; +use std::collections::BTreeMap; use std::time::Duration; use libp2p::futures::prelude::*; @@ -37,7 +38,7 @@ pub async fn run( relay_addresses: Vec, rendezvous_addresses: Vec, ) -> eyre::Result<(NetworkClient, mpsc::Receiver)> { - let mut rendezvous = HashMap::new(); + let mut rendezvous = BTreeMap::new(); for address in &rendezvous_addresses { let entry = match peek_peer_id(&address) { Ok(peer_id) => (peer_id, RendezvousEntry::new(address.clone())), @@ -48,7 +49,7 @@ pub async fn run( rendezvous.insert(entry.0, entry.1); } - let mut relays = HashMap::new(); + let mut relays = BTreeMap::new(); for address in &relay_addresses { let entry = match peek_peer_id(&address) { Ok(peer_id) => (peer_id, RelayEntry::new(address.clone())), @@ -105,9 +106,9 @@ async fn run_init_dial( async fn init( keypair: identity::Keypair, - relays: HashMap, + relays: BTreeMap, rendezvous_namespace: rendezvous::Namespace, - rendezvous: HashMap, + rendezvous: BTreeMap, ) -> eyre::Result<( NetworkClient, mpsc::Receiver, @@ -166,9 +167,9 @@ pub(crate) struct EventLoop { swarm: Swarm, command_receiver: mpsc::Receiver, event_sender: mpsc::Sender, - relays: HashMap, + relays: BTreeMap, rendezvous_namespace: rendezvous::Namespace, - rendezvous: HashMap, + rendezvous: BTreeMap, pending_dial: HashMap>>>, } @@ -231,9 +232,9 @@ impl EventLoop { swarm: Swarm, command_receiver: mpsc::Receiver, event_sender: mpsc::Sender, - relays: HashMap, + relays: BTreeMap, rendezvous_namespace: rendezvous::Namespace, - rendezvous: HashMap, + rendezvous: BTreeMap, ) -> Self { Self { swarm,