mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-27 16:51:34 +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>)
|
-> (SwarmController<T, C>, SwarmFuture<T, C, H, F::Future>)
|
||||||
where T: MuxedTransport + Clone + 'static, // TODO: 'static :-/
|
where T: MuxedTransport + Clone + 'static, // TODO: 'static :-/
|
||||||
C: ConnectionUpgrade<T::RawConn> + Clone + 'static, // TODO: 'static :-/
|
C: ConnectionUpgrade<T::RawConn> + Clone + 'static, // TODO: 'static :-/
|
||||||
|
C::NamesIter: Clone, // TODO: not elegant
|
||||||
H: FnMut(C::Output, Multiaddr) -> F,
|
H: FnMut(C::Output, Multiaddr) -> F,
|
||||||
F: IntoFuture<Item = (), Error = IoError>,
|
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>
|
impl<T, C, H, If, F> Future for SwarmFuture<T, C, H, F>
|
||||||
where T: MuxedTransport + Clone + 'static, // TODO: 'static :-/,
|
where T: MuxedTransport + Clone + 'static, // TODO: 'static :-/,
|
||||||
C: ConnectionUpgrade<T::RawConn> + Clone + 'static, // TODO: 'static :-/
|
C: ConnectionUpgrade<T::RawConn> + Clone + 'static, // TODO: 'static :-/
|
||||||
|
C::NamesIter: Clone, // TODO: not elegant
|
||||||
H: FnMut(C::Output, Multiaddr) -> If,
|
H: FnMut(C::Output, Multiaddr) -> If,
|
||||||
If: IntoFuture<Future = F, Item = (), Error = IoError>,
|
If: IntoFuture<Future = F, Item = (), Error = IoError>,
|
||||||
F: Future<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()));
|
self.to_process.push(future::Either::A(handler(connec, client_addr).into_future()));
|
||||||
},
|
},
|
||||||
Ok(Async::NotReady) => {},
|
Ok(Async::NotReady) => {},
|
||||||
|
// TODO: may not be the best idea because we're killing the whole server
|
||||||
Err(err) => return Err(err),
|
Err(err) => return Err(err),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -811,7 +811,9 @@ where
|
|||||||
/// This function returns the next incoming substream. You are strongly encouraged to call it
|
/// This function returns the next incoming substream. You are strongly encouraged to call it
|
||||||
/// if you have a muxed transport.
|
/// if you have a muxed transport.
|
||||||
pub fn next_incoming(self) -> Box<Future<Item = (C::Output, Multiaddr), Error = IoError> + 'a>
|
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;
|
let upgrade = self.upgrade;
|
||||||
|
|
||||||
@ -819,8 +821,8 @@ where
|
|||||||
// Try to negotiate the protocol.
|
// Try to negotiate the protocol.
|
||||||
.and_then(move |(connection, addr)| {
|
.and_then(move |(connection, addr)| {
|
||||||
let iter = upgrade.protocol_names()
|
let iter = upgrade.protocol_names()
|
||||||
.map(|(name, id)| (name, <Bytes as PartialEq>::eq, id));
|
.map::<_, fn(_) -> _>(|(name, id)| (name, <Bytes as PartialEq>::eq, id));
|
||||||
let negotiated = multistream_select::dialer_select_proto(connection, iter)
|
let negotiated = multistream_select::listener_select_proto(connection, iter)
|
||||||
.map_err(|err| IoError::new(IoErrorKind::Other, err));
|
.map_err(|err| IoError::new(IoErrorKind::Other, err));
|
||||||
negotiated.map(|(upgrade_id, conn)| (upgrade_id, conn, upgrade, addr))
|
negotiated.map(|(upgrade_id, conn)| (upgrade_id, conn, upgrade, addr))
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user