mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-28 01:01:34 +00:00
refactor(core)!: remove EitherOutput
(#3341)
The trick with this one is to use `futures::Either` everywhere where we may wrap something that implements any of the `futures` traits. This includes the output of `EitherFuture` itself. We also need to implement `StreamMuxer` on `future::Either` because `StreamMuxer`s may be the the `Output` of `InboundUpgrade`.
This commit is contained in:
@ -26,7 +26,6 @@ use futures::future::BoxFuture;
|
||||
use futures::prelude::*;
|
||||
use futures::stream::FuturesUnordered;
|
||||
use futures_timer::Delay;
|
||||
use libp2p_core::either::EitherOutput;
|
||||
use libp2p_core::upgrade::SelectUpgrade;
|
||||
use libp2p_core::{ConnectedPoint, Multiaddr, PeerId, PublicKey};
|
||||
use libp2p_swarm::handler::{
|
||||
@ -201,7 +200,7 @@ impl Handler {
|
||||
>,
|
||||
) {
|
||||
match output {
|
||||
EitherOutput::First(substream) => {
|
||||
future::Either::Left(substream) => {
|
||||
self.events
|
||||
.push(ConnectionHandlerEvent::Custom(Event::Identify));
|
||||
if !self.reply_streams.is_empty() {
|
||||
@ -213,7 +212,7 @@ impl Handler {
|
||||
}
|
||||
self.reply_streams.push_back(substream);
|
||||
}
|
||||
EitherOutput::Second(fut) => {
|
||||
future::Either::Right(fut) => {
|
||||
if self.inbound_identify_push.replace(fut).is_some() {
|
||||
warn!(
|
||||
"New inbound identify push stream from {} while still \
|
||||
@ -235,14 +234,14 @@ impl Handler {
|
||||
>,
|
||||
) {
|
||||
match output {
|
||||
EitherOutput::First(remote_info) => {
|
||||
future::Either::Left(remote_info) => {
|
||||
self.events
|
||||
.push(ConnectionHandlerEvent::Custom(Event::Identified(
|
||||
remote_info,
|
||||
)));
|
||||
self.keep_alive = KeepAlive::No;
|
||||
}
|
||||
EitherOutput::Second(()) => self
|
||||
future::Either::Right(()) => self
|
||||
.events
|
||||
.push(ConnectionHandlerEvent::Custom(Event::IdentificationPushed)),
|
||||
}
|
||||
|
Reference in New Issue
Block a user