mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-27 00:31:35 +00:00
Merge pull request #92 from tomaka/wrong-mulstream-endpoint
Fix using the wrong multistream endpoint
This commit is contained in:
@ -35,6 +35,7 @@ pub fn swarm<T, C, H, F>(transport: T, upgrade: C, handler: H)
|
||||
-> (SwarmController<T, C>, SwarmFuture<T, C, H, F::Future>)
|
||||
where T: MuxedTransport + Clone + 'static, // TODO: 'static :-/
|
||||
C: ConnectionUpgrade<T::RawConn> + Clone + 'static, // TODO: 'static :-/
|
||||
C::NamesIter: Clone, // TODO: not elegant
|
||||
H: FnMut(C::Output, Multiaddr) -> F,
|
||||
F: IntoFuture<Item = (), Error = IoError>,
|
||||
{
|
||||
@ -170,6 +171,7 @@ pub struct SwarmFuture<T, C, H, F>
|
||||
impl<T, C, H, If, F> Future for SwarmFuture<T, C, H, F>
|
||||
where T: MuxedTransport + Clone + 'static, // TODO: 'static :-/,
|
||||
C: ConnectionUpgrade<T::RawConn> + Clone + 'static, // TODO: 'static :-/
|
||||
C::NamesIter: Clone, // TODO: not elegant
|
||||
H: FnMut(C::Output, Multiaddr) -> If,
|
||||
If: IntoFuture<Future = F, Item = (), Error = IoError>,
|
||||
F: Future<Item = (), Error = IoError>,
|
||||
@ -186,6 +188,7 @@ impl<T, C, H, If, F> Future for SwarmFuture<T, C, H, F>
|
||||
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),
|
||||
};
|
||||
|
||||
|
@ -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<Future<Item = (C::Output, Multiaddr), Error = IoError> + '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, <Bytes as PartialEq>::eq, id));
|
||||
let negotiated = multistream_select::dialer_select_proto(connection, iter)
|
||||
.map::<_, fn(_) -> _>(|(name, id)| (name, <Bytes as PartialEq>::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))
|
||||
})
|
||||
|
Reference in New Issue
Block a user