diff --git a/libp2p-swarm/src/swarm.rs b/libp2p-swarm/src/swarm.rs index 8d1e27bd..7f1cea45 100644 --- a/libp2p-swarm/src/swarm.rs +++ b/libp2p-swarm/src/swarm.rs @@ -35,6 +35,7 @@ pub fn swarm(transport: T, upgrade: C, handler: H) -> (SwarmController, SwarmFuture) where T: MuxedTransport + Clone + 'static, // TODO: 'static :-/ C: ConnectionUpgrade + Clone + 'static, // TODO: 'static :-/ + C::NamesIter: Clone, // TODO: not elegant H: FnMut(C::Output, Multiaddr) -> F, F: IntoFuture, { @@ -170,6 +171,7 @@ pub struct SwarmFuture impl Future for SwarmFuture where T: MuxedTransport + Clone + 'static, // TODO: 'static :-/, C: ConnectionUpgrade + Clone + 'static, // TODO: 'static :-/ + C::NamesIter: Clone, // TODO: not elegant H: FnMut(C::Output, Multiaddr) -> If, If: IntoFuture, F: Future, @@ -186,6 +188,7 @@ impl Future for SwarmFuture self.to_process.push(future::Either::A(handler(connec, client_addr).into_future())); }, Ok(Async::NotReady) => {}, + // TODO: may not be the best idea because we're killing the whole server Err(err) => return Err(err), }; diff --git a/libp2p-swarm/src/transport.rs b/libp2p-swarm/src/transport.rs index 8099f988..15042a6d 100644 --- a/libp2p-swarm/src/transport.rs +++ b/libp2p-swarm/src/transport.rs @@ -811,7 +811,9 @@ where /// This function returns the next incoming substream. You are strongly encouraged to call it /// if you have a muxed transport. pub fn next_incoming(self) -> Box + 'a> - where T: MuxedTransport + where T: MuxedTransport, + C::NamesIter: Clone, // TODO: not elegant + C: Clone, { let upgrade = self.upgrade; @@ -819,8 +821,8 @@ where // Try to negotiate the protocol. .and_then(move |(connection, addr)| { let iter = upgrade.protocol_names() - .map(|(name, id)| (name, ::eq, id)); - let negotiated = multistream_select::dialer_select_proto(connection, iter) + .map::<_, fn(_) -> _>(|(name, id)| (name, ::eq, id)); + let negotiated = multistream_select::listener_select_proto(connection, iter) .map_err(|err| IoError::new(IoErrorKind::Other, err)); negotiated.map(|(upgrade_id, conn)| (upgrade_id, conn, upgrade, addr)) })