mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-17 03:51:22 +00:00
feat(swarm)!: introduce ListenError
(#3375)
In case an error happens for an outgoing connection, `Pool` reports an `OutgoingConnectionError`. This one is mapped to a `DialError` and reported via `SwarmEvent::OutgoingConnectionError` and `FromSwarm::DialFailure`. For incoming connections, we didn't quite do the same thing. For one, `SwarmEvent::IncomingConnectionError` directly contained a `PendingInboundConnectionError`. Two, `FromSwarm::ListenFailure` did not include an error at all. With this patch, we now introduce a `ListenError` enum which we use in `SwarmEvent::IncomingConnectionError` and we pass a reference to it along in `FromSwarm::ListenFailure`.
This commit is contained in:
@ -29,7 +29,7 @@ pub use listen_addresses::ListenAddresses;
|
||||
use crate::connection::ConnectionId;
|
||||
use crate::dial_opts::DialOpts;
|
||||
use crate::handler::{ConnectionHandler, IntoConnectionHandler};
|
||||
use crate::{AddressRecord, AddressScore, DialError, THandlerOutEvent};
|
||||
use crate::{AddressRecord, AddressScore, DialError, ListenError, THandlerOutEvent};
|
||||
use libp2p_core::{transport::ListenerId, ConnectedPoint, Multiaddr, PeerId};
|
||||
use std::{task::Context, task::Poll};
|
||||
|
||||
@ -742,6 +742,7 @@ pub struct DialFailure<'a, Handler> {
|
||||
pub struct ListenFailure<'a, Handler> {
|
||||
pub local_addr: &'a Multiaddr,
|
||||
pub send_back_addr: &'a Multiaddr,
|
||||
pub error: &'a ListenError,
|
||||
pub handler: Handler,
|
||||
}
|
||||
|
||||
@ -870,10 +871,12 @@ impl<'a, Handler: IntoConnectionHandler> FromSwarm<'a, Handler> {
|
||||
FromSwarm::ListenFailure(ListenFailure {
|
||||
local_addr,
|
||||
send_back_addr,
|
||||
error,
|
||||
handler,
|
||||
}) => Some(FromSwarm::ListenFailure(ListenFailure {
|
||||
local_addr,
|
||||
send_back_addr,
|
||||
error,
|
||||
handler: map_into_handler(handler)?,
|
||||
})),
|
||||
FromSwarm::NewListener(NewListener { listener_id }) => {
|
||||
|
Reference in New Issue
Block a user