Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions misc/metrics/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,44 +51,23 @@ struct EventLabels {
#[derive(Debug, Clone, Hash, PartialEq, Eq, EncodeLabelValue)]
enum EventType {
ReservationReqAccepted,
ReservationReqAcceptFailed,
ReservationReqDenied,
ReservationReqDenyFailed,
ReservationClosed,
ReservationTimedOut,
CircuitReqDenied,
CircuitReqDenyFailed,
CircuitReqOutboundConnectFailed,
CircuitReqAccepted,
CircuitReqAcceptFailed,
CircuitClosed,
}

impl From<&libp2p_relay::Event> for EventType {
fn from(event: &libp2p_relay::Event) -> Self {
match event {
libp2p_relay::Event::ReservationReqAccepted { .. } => EventType::ReservationReqAccepted,
#[allow(deprecated)]
libp2p_relay::Event::ReservationReqAcceptFailed { .. } => {
EventType::ReservationReqAcceptFailed
}
libp2p_relay::Event::ReservationReqDenied { .. } => EventType::ReservationReqDenied,
#[allow(deprecated)]
libp2p_relay::Event::ReservationReqDenyFailed { .. } => {
EventType::ReservationReqDenyFailed
}
libp2p_relay::Event::ReservationClosed { .. } => EventType::ReservationClosed,
libp2p_relay::Event::ReservationTimedOut { .. } => EventType::ReservationTimedOut,
libp2p_relay::Event::CircuitReqDenied { .. } => EventType::CircuitReqDenied,
#[allow(deprecated)]
libp2p_relay::Event::CircuitReqOutboundConnectFailed { .. } => {
EventType::CircuitReqOutboundConnectFailed
}
#[allow(deprecated)]
libp2p_relay::Event::CircuitReqDenyFailed { .. } => EventType::CircuitReqDenyFailed,
libp2p_relay::Event::CircuitReqAccepted { .. } => EventType::CircuitReqAccepted,
#[allow(deprecated)]
libp2p_relay::Event::CircuitReqAcceptFailed { .. } => EventType::CircuitReqAcceptFailed,
libp2p_relay::Event::CircuitClosed { .. } => EventType::CircuitClosed,
}
}
Expand Down
116 changes: 29 additions & 87 deletions protocols/relay/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ use libp2p_swarm::{
};
use web_time::Instant;

use crate::{
behaviour::handler::Handler,
multiaddr_ext::MultiaddrExt,
proto,
protocol::{inbound_hop, outbound_stop},
};
use crate::{behaviour::handler::Handler, multiaddr_ext::MultiaddrExt, proto};

/// Configuration for the relay [`Behaviour`].
///
Expand Down Expand Up @@ -175,27 +170,11 @@ pub enum Event {
/// Indicates whether the request replaces an existing reservation.
renewed: bool,
},
/// Accepting an inbound reservation request failed.
#[deprecated(
note = "Will be removed in favor of logging them internally, see <https://github.com/libp2p/rust-libp2p/issues/4757> for details."
)]
ReservationReqAcceptFailed {
src_peer_id: PeerId,
error: inbound_hop::Error,
},
/// An inbound reservation request has been denied.
ReservationReqDenied {
src_peer_id: PeerId,
status: StatusCode,
},
/// Denying an inbound reservation request has failed.
#[deprecated(
note = "Will be removed in favor of logging them internally, see <https://github.com/libp2p/rust-libp2p/issues/4757> for details."
)]
ReservationReqDenyFailed {
src_peer_id: PeerId,
error: inbound_hop::Error,
},
/// A reservation has been closed.
ReservationClosed { src_peer_id: PeerId },
/// An inbound reservation has timed out.
Expand All @@ -206,38 +185,11 @@ pub enum Event {
dst_peer_id: PeerId,
status: StatusCode,
},
/// Denying an inbound circuit request failed.
#[deprecated(
note = "Will be removed in favor of logging them internally, see <https://github.com/libp2p/rust-libp2p/issues/4757> for details."
)]
CircuitReqDenyFailed {
src_peer_id: PeerId,
dst_peer_id: PeerId,
error: inbound_hop::Error,
},
/// An inbound circuit request has been accepted.
CircuitReqAccepted {
src_peer_id: PeerId,
dst_peer_id: PeerId,
},
/// An outbound connect for an inbound circuit request failed.
#[deprecated(
note = "Will be removed in favor of logging them internally, see <https://github.com/libp2p/rust-libp2p/issues/4757> for details."
)]
CircuitReqOutboundConnectFailed {
src_peer_id: PeerId,
dst_peer_id: PeerId,
error: outbound_stop::Error,
},
/// Accepting an inbound circuit request failed.
#[deprecated(
note = "Will be removed in favor of logging them internally, see <https://github.com/libp2p/rust-libp2p/issues/4757> for details."
)]
CircuitReqAcceptFailed {
src_peer_id: PeerId,
dst_peer_id: PeerId,
error: inbound_hop::Error,
},
/// An inbound circuit has closed.
CircuitClosed {
src_peer_id: PeerId,
Expand Down Expand Up @@ -477,13 +429,11 @@ impl NetworkBehaviour for Behaviour {
));
}
handler::Event::ReservationReqAcceptFailed { error } => {
#[allow(deprecated)]
self.queued_actions.push_back(ToSwarm::GenerateEvent(
Event::ReservationReqAcceptFailed {
src_peer_id: event_source,
error,
},
));
tracing::warn!(
peer=%event_source,
?error,
"Accepting inbound reservation request failed"
);
}
handler::Event::ReservationReqDenied { status } => {
self.queued_actions.push_back(ToSwarm::GenerateEvent(
Expand All @@ -494,13 +444,11 @@ impl NetworkBehaviour for Behaviour {
));
}
handler::Event::ReservationReqDenyFailed { error } => {
#[allow(deprecated)]
self.queued_actions.push_back(ToSwarm::GenerateEvent(
Event::ReservationReqDenyFailed {
src_peer_id: event_source,
error,
},
));
tracing::warn!(
peer=%event_source,
?error,
"Denying inbound reservation request failed"
);
}
handler::Event::ReservationTimedOut {} => {
match self.reservations.entry(event_source) {
Expand Down Expand Up @@ -619,14 +567,12 @@ impl NetworkBehaviour for Behaviour {
self.circuits.remove(circuit_id);
}

#[allow(deprecated)]
self.queued_actions.push_back(ToSwarm::GenerateEvent(
Event::CircuitReqDenyFailed {
src_peer_id: event_source,
dst_peer_id,
error,
},
));
tracing::warn!(
src_peer=%event_source,
dst_peer=%dst_peer_id,
?error,
"Denying inbound circuit request failed"
);
}
handler::Event::OutboundConnectNegotiated {
circuit_id,
Expand Down Expand Up @@ -665,14 +611,12 @@ impl NetworkBehaviour for Behaviour {
status,
}),
});
#[allow(deprecated)]
self.queued_actions.push_back(ToSwarm::GenerateEvent(
Event::CircuitReqOutboundConnectFailed {
src_peer_id,
dst_peer_id: event_source,
error,
},
));
tracing::warn!(
src_peer=%src_peer_id,
dst_peer=%event_source,
?error,
"Outbound connect for inbound circuit request failed"
);
}
handler::Event::CircuitReqAccepted {
dst_peer_id,
Expand All @@ -691,14 +635,12 @@ impl NetworkBehaviour for Behaviour {
error,
} => {
self.circuits.remove(circuit_id);
#[allow(deprecated)]
self.queued_actions.push_back(ToSwarm::GenerateEvent(
Event::CircuitReqAcceptFailed {
src_peer_id: event_source,
dst_peer_id,
error,
},
));
tracing::warn!(
src_peer=%event_source,
dst_peer=%dst_peer_id,
?error,
"Accepting inbound circuit request failed"
);
}
handler::Event::CircuitClosed {
dst_peer_id,
Expand Down