Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ multicast-socket = "0.2.1"
hex = "0.4.3"
pretty-hash = "0.4.1"
hyperswarm-dht = { git = "https://github.com/Frando/hyperswarm-dht.git", branch = "hyperspace" }
colmeia-hyperswarm-mdns = { git = "https://github.com/bltavares/colmeia.git", rev = "e92ab71981356197a21592b7ce6854e209582985" }
colmeia-hyperswarm-mdns = { git = "https://github.com/bltavares/colmeia.git", rev = "53761799f7a9ee123875534e0108d7483a117885" }
libutp-rs = { git = "https://github.com/Frando/libutp-rs.git", branch = "feat/clone", optional = true }

[dev-dependencies]
Expand Down
44 changes: 21 additions & 23 deletions src/discovery/mdns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use async_std::channel;
use async_std::stream::Stream;
use async_std::task::{Context, Poll};
use colmeia_hyperswarm_mdns::{self_id, Announcer, Locator};
use futures::FutureExt;
use futures_lite::ready;
// use log::*;
use std::convert::TryInto;
Expand Down Expand Up @@ -108,29 +109,26 @@ impl Stream for MdnsDiscovery {
return Poll::Ready(Some(Err(e)));
}

if let Poll::Ready(Some(_command)) = Pin::new(&mut this.pending_commands_rx).poll_next(cx) {
// TODO: Boxing the add_topic future does not work because there's no valid
// lifetime. Best would be to make the add_topic functions sync, or return
// a future that can be boxed.
// let fut = match command {
// Command::Lookup(topic) => {
// let fut = this.locator.add_topic(&topic);
// let fut = fut.map(|r| {
// r.map_err(|e| io::Error::new(io::ErrorKind::Other, format!("{}", e)))
// });
// let fut: CommandFut = fut.boxed();
// fut
// }
// Command::Announce(topic) => {
// let fut = this.announcer.add_topic(&topic);
// let fut = fut.map(|r| {
// r.map_err(|e| io::Error::new(io::ErrorKind::Other, format!("{}", e)))
// });
// let fut: CommandFut = fut.boxed();
// fut
// }
// };
// this.pending_future = Some(fut);
if let Poll::Ready(Some(command)) = Pin::new(&mut this.pending_commands_rx).poll_next(cx) {
let fut = match command {
Command::Lookup(topic) => {
let fut = this.locator.add_topic(topic.to_vec());
let fut = fut.map(|r| {
r.map_err(|e| io::Error::new(io::ErrorKind::Other, format!("{}", e)))
});
let fut: CommandFut = fut.boxed();
fut
}
Command::Announce(topic) => {
let fut = this.announcer.add_topic(topic.to_vec());
let fut = fut.map(|r| {
r.map_err(|e| io::Error::new(io::ErrorKind::Other, format!("{}", e)))
});
let fut: CommandFut = fut.boxed();
fut
}
};
this.pending_future = Some(fut);
}

if let Err(e) = ready!(this.poll_pending_future(cx)) {
Expand Down