mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-31 00:41:59 +00:00
More precise error passed to inject_dial_upgrade_error (#771)
* More precise error passed to inject_dial_upgrade_error * Fix concerns * Fix panic proof
This commit is contained in:
@@ -23,7 +23,7 @@ use crate::periodic_id_handler::{PeriodicIdHandler, PeriodicIdHandlerEvent};
|
||||
use crate::protocol::{IdentifyInfo, IdentifySender, IdentifySenderFuture};
|
||||
use crate::topology::IdentifyTopology;
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::protocols_handler::{ProtocolsHandler, ProtocolsHandlerSelect};
|
||||
use libp2p_core::protocols_handler::{ProtocolsHandler, ProtocolsHandlerSelect, ProtocolsHandlerUpgrErr};
|
||||
use libp2p_core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
|
||||
use libp2p_core::{Multiaddr, PeerId, either::EitherOutput, topology::Topology};
|
||||
use smallvec::SmallVec;
|
||||
@@ -192,6 +192,6 @@ pub enum IdentifyEvent {
|
||||
/// Peer that we fail to identify.
|
||||
peer_id: PeerId,
|
||||
/// The error that happened.
|
||||
error: io::Error,
|
||||
error: ProtocolsHandlerUpgrErr<io::Error>,
|
||||
},
|
||||
}
|
||||
|
@@ -21,8 +21,8 @@
|
||||
use crate::protocol::{IdentifySender, IdentifyProtocolConfig};
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::{
|
||||
protocols_handler::{ProtocolsHandler, ProtocolsHandlerEvent},
|
||||
upgrade::{DeniedUpgrade, InboundUpgrade}
|
||||
protocols_handler::{ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr},
|
||||
upgrade::{DeniedUpgrade, InboundUpgrade, OutboundUpgrade}
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::io;
|
||||
@@ -87,7 +87,7 @@ where
|
||||
fn inject_inbound_closed(&mut self) {}
|
||||
|
||||
#[inline]
|
||||
fn inject_dial_upgrade_error(&mut self, _: Self::OutboundOpenInfo, _: io::Error) {}
|
||||
fn inject_dial_upgrade_error(&mut self, _: Self::OutboundOpenInfo, _: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>) {}
|
||||
|
||||
#[inline]
|
||||
fn shutdown(&mut self) {
|
||||
|
@@ -21,7 +21,7 @@
|
||||
use crate::protocol::{RemoteInfo, IdentifyProtocolConfig};
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::{
|
||||
protocols_handler::{ProtocolsHandler, ProtocolsHandlerEvent},
|
||||
protocols_handler::{ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr},
|
||||
upgrade::{DeniedUpgrade, OutboundUpgrade}
|
||||
};
|
||||
use std::{io, marker::PhantomData, time::{Duration, Instant}};
|
||||
@@ -59,7 +59,7 @@ pub enum PeriodicIdHandlerEvent {
|
||||
/// We obtained identification information from the remote
|
||||
Identified(RemoteInfo),
|
||||
/// Failed to identify the remote.
|
||||
IdentificationError(io::Error),
|
||||
IdentificationError(ProtocolsHandlerUpgrErr<io::Error>),
|
||||
}
|
||||
|
||||
impl<TSubstream> PeriodicIdHandler<TSubstream> {
|
||||
@@ -110,7 +110,7 @@ where
|
||||
fn inject_inbound_closed(&mut self) {}
|
||||
|
||||
#[inline]
|
||||
fn inject_dial_upgrade_error(&mut self, _: Self::OutboundOpenInfo, err: io::Error) {
|
||||
fn inject_dial_upgrade_error(&mut self, _: Self::OutboundOpenInfo, err: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>) {
|
||||
self.pending_result = Some(PeriodicIdHandlerEvent::IdentificationError(err));
|
||||
if let Some(ref mut next_id) = self.next_id {
|
||||
next_id.reset(Instant::now() + TRY_AGAIN_ON_ERR);
|
||||
|
Reference in New Issue
Block a user