upgrade::or() requires same Output (#218)

This commit is contained in:
Pierre Krieger
2018-05-24 16:37:12 +02:00
committed by GitHub
parent c7f654a815
commit c1cd10c034
7 changed files with 36 additions and 22 deletions

View File

@ -29,7 +29,7 @@ use futures::Future;
use futures::sync::oneshot;
use std::env;
use libp2p::core::Transport;
use libp2p::core::upgrade;
use libp2p::core::{upgrade, either::EitherOutput};
use libp2p::tcp::TcpConfig;
use tokio_core::reactor::Core;
@ -61,7 +61,10 @@ fn main() {
}
};
upgrade::or(plain_text, upgrade::map(secio, |(socket, _)| socket))
upgrade::or(
upgrade::map(plain_text, |pt| EitherOutput::First(pt)),
upgrade::map(secio, |(socket, _)| EitherOutput::Second(socket))
)
})
// On top of plaintext or secio, we will use the multiplex protocol.