* New core

* Fix lifetime requirements

* Remove identify transport

* Address &mut & ref ref mut

* Fix whitespaces
This commit is contained in:
Pierre Krieger
2018-10-17 10:17:40 +01:00
committed by GitHub
parent 724d0f5d82
commit 5d1c54cc10
52 changed files with 849 additions and 1492 deletions

View File

@ -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();