mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-31 00:41:59 +00:00
New core (#568)
* New core * Fix lifetime requirements * Remove identify transport * Address &mut & ref ref mut * Fix whitespaces
This commit is contained in:
@@ -64,7 +64,7 @@ impl KadConnecConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, Maf> ConnectionUpgrade<C, Maf> for KadConnecConfig
|
||||
impl<C> ConnectionUpgrade<C> for KadConnecConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Send + 'static, // TODO: 'static :-/
|
||||
{
|
||||
@@ -72,22 +72,21 @@ where
|
||||
KadConnecController,
|
||||
Box<Stream<Item = KadIncomingRequest, Error = IoError> + Send>,
|
||||
);
|
||||
type MultiaddrFuture = Maf;
|
||||
type Future = future::Map<<KademliaProtocolConfig as ConnectionUpgrade<C, Maf>>::Future, fn((<KademliaProtocolConfig as ConnectionUpgrade<C, Maf>>::Output, Maf)) -> (Self::Output, Maf)>;
|
||||
type Future = future::Map<<KademliaProtocolConfig as ConnectionUpgrade<C>>::Future, fn(<KademliaProtocolConfig as ConnectionUpgrade<C>>::Output) -> Self::Output>;
|
||||
type NamesIter = iter::Once<(Bytes, ())>;
|
||||
type UpgradeIdentifier = ();
|
||||
|
||||
#[inline]
|
||||
fn protocol_names(&self) -> Self::NamesIter {
|
||||
ConnectionUpgrade::<C, Maf>::protocol_names(&self.raw_proto)
|
||||
ConnectionUpgrade::<C>::protocol_names(&self.raw_proto)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn upgrade(self, incoming: C, id: (), endpoint: Endpoint, addr: Maf) -> Self::Future {
|
||||
fn upgrade(self, incoming: C, id: (), endpoint: Endpoint) -> Self::Future {
|
||||
self.raw_proto
|
||||
.upgrade(incoming, id, endpoint, addr)
|
||||
.map::<fn(_) -> _, _>(move |(connec, addr)| {
|
||||
(build_from_sink_stream(connec), addr)
|
||||
.upgrade(incoming, id, endpoint)
|
||||
.map::<fn(_) -> _, _>(move |connec| {
|
||||
build_from_sink_stream(connec)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -128,13 +128,12 @@ impl Into<protobuf_structs::dht::Message_Peer> for KadPeer {
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct KademliaProtocolConfig;
|
||||
|
||||
impl<C, Maf> ConnectionUpgrade<C, Maf> for KademliaProtocolConfig
|
||||
impl<C> ConnectionUpgrade<C> for KademliaProtocolConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + 'static, // TODO: 'static :-/
|
||||
{
|
||||
type Output = KadStreamSink<C>;
|
||||
type MultiaddrFuture = Maf;
|
||||
type Future = future::FutureResult<(Self::Output, Self::MultiaddrFuture), IoError>;
|
||||
type Future = future::FutureResult<Self::Output, IoError>;
|
||||
type NamesIter = iter::Once<(Bytes, ())>;
|
||||
type UpgradeIdentifier = ();
|
||||
|
||||
@@ -144,8 +143,8 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn upgrade(self, incoming: C, _: (), _: Endpoint, addr: Maf) -> Self::Future {
|
||||
future::ok((kademlia_protocol(incoming), addr))
|
||||
fn upgrade(self, incoming: C, _: (), _: Endpoint) -> Self::Future {
|
||||
future::ok(kademlia_protocol(incoming))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,7 +488,7 @@ mod tests {
|
||||
let future = listener
|
||||
.into_future()
|
||||
.map_err(|(err, _)| err)
|
||||
.and_then(|(client, _)| client.unwrap().map(|v| v.0))
|
||||
.and_then(|(client, _)| client.unwrap().0)
|
||||
.and_then(|proto| proto.into_future().map_err(|(err, _)| err).map(|(v, _)| v))
|
||||
.map(|recv_msg| {
|
||||
assert_eq!(recv_msg.unwrap(), msg_server);
|
||||
@@ -504,7 +503,7 @@ mod tests {
|
||||
let future = transport
|
||||
.dial(rx.recv().unwrap())
|
||||
.unwrap_or_else(|_| panic!())
|
||||
.and_then(|proto| proto.0.send(msg_client))
|
||||
.and_then(|proto| proto.send(msg_client))
|
||||
.map(|_| ());
|
||||
|
||||
let _ = tokio_current_thread::block_on_all(future).unwrap();
|
||||
|
Reference in New Issue
Block a user