Change Transport::Dial to be Future and not IntoFuture (#193)

This commit is contained in:
Pierre Krieger
2018-05-17 13:09:22 +02:00
committed by GitHub
parent 5c1890e66a
commit cb800624f5
8 changed files with 19 additions and 35 deletions

View File

@ -179,7 +179,7 @@ where
debug!(target: "libp2p-core", "No existing connection to {}; dialing", addr);
match inner.dial(addr.clone()) {
Ok(dial) => {
let future = dial.into_future().and_then(move |(muxer, addr)| {
let future = dial.and_then(move |(muxer, addr)| {
muxer.clone().outbound().and_then(move |substream| {
if let Some(s) = substream {
// Replace the active connection because we are the most recent.

View File

@ -123,8 +123,7 @@ where
match transport.dial(multiaddr.clone()) {
Ok(dial) => {
let dial = Box::new(
dial.into_future()
.map(|(d, client_addr)| (d.into(), client_addr)),
dial.map(|(d, client_addr)| (d.into(), client_addr)),
) as Box<Future<Item = _, Error = _>>;
// Ignoring errors if the receiver has been closed, because in that situation
// nothing is going to be processed anyway.
@ -156,7 +155,7 @@ where
match transport.dial(multiaddr) {
Ok(dial) => {
let dial = Box::new(dial.into_future().and_then(|(d, m)| and_then(d, m))) as Box<_>;
let dial = Box::new(dial.and_then(|(d, m)| and_then(d, m))) as Box<_>;
// Ignoring errors if the receiver has been closed, because in that situation
// nothing is going to be processed anyway.
let _ = self.new_toprocess.unbounded_send(dial);

View File

@ -85,7 +85,7 @@ where
let upgrade = self.upgrade;
let dialed_fut = match self.transport.dial(addr.clone()) {
Ok(f) => f.into_future(),
Ok(f) => f,
Err((trans, addr)) => {
let builder = AndThen {
transport: trans,

View File

@ -59,12 +59,12 @@ where
fn dial(self, addr: Multiaddr) -> Result<Self::Dial, (Self, Multiaddr)> {
let (first, addr) = match self.0.dial(addr) {
Ok(connec) => return Ok(EitherListenUpgrade::First(connec.into_future())),
Ok(connec) => return Ok(EitherListenUpgrade::First(connec)),
Err(err) => err,
};
match self.1.dial(addr) {
Ok(connec) => Ok(EitherListenUpgrade::Second(connec.into_future())),
Ok(connec) => Ok(EitherListenUpgrade::Second(connec)),
Err((second, addr)) => Err((OrTransport(first, second), addr)),
}
}

View File

@ -76,7 +76,7 @@ pub trait Transport {
type ListenerUpgrade: Future<Item = (Self::Output, Multiaddr), Error = IoError>;
/// A future which indicates that we are currently dialing to a peer.
type Dial: IntoFuture<Item = (Self::Output, Multiaddr), Error = IoError>;
type Dial: Future<Item = (Self::Output, Multiaddr), Error = IoError>;
/// Listen on the given multiaddr. Returns a stream of incoming connections, plus a modified
/// version of the `Multiaddr`. This new `Multiaddr` is the one that that should be advertised

View File

@ -84,7 +84,7 @@ where
let upgrade = self.upgrade;
let dialed_fut = match self.transports.dial(addr.clone()) {
Ok(f) => f.into_future(),
Ok(f) => f,
Err((trans, addr)) => {
let builder = UpgradedNode {
transports: trans,