Commit c2b0e362 authored by Kaiden Fey's avatar Kaiden Fey Committed by Katharina Fey

hubd: updating netmod-tcp usage to pass peers as strings

parent 99528628
use std::path::PathBuf;
/// The hub configuration
pub(crate) struct Config {
/// Path to initial peer set
pub(crate) peers: PathBuf,
/// Runtime mode (in netmod-tcp)
pub(crate) mode: String,
}
......@@ -33,20 +33,8 @@ impl State {
let mut peersfd = File::open(&cfg.peers).unwrap();
peersfd.read_to_string(&mut buf).unwrap();
let peers = buf
.split("\n")
.into_iter()
.fold(HashSet::new(), |mut set, peer| {
if peer != "" {
set.insert(
SocketAddr::from_str(&peer)
.expect(&format!("Peer `{}` had a bad format!", &peer)),
);
}
set
});
ep.add_peers(peers.into_iter().collect()).await.unwrap();
let peers = buf.split("\n").map(|s| s.to_string()).collect();
ep.add_peers(peers).await.unwrap();
let router = Router::new();
router.add_endpoint(ep).await;
......
......@@ -24,7 +24,7 @@ pub enum Params {
Tcp {
addr: String,
port: u16,
peers: Vec<SocketAddr>,
peers: Vec<String>,
dynamic: bool,
},
/// Purely local udp broadcast endpoint
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment