Skip to content

Commit

Permalink
Deprecate event variants
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger committed Oct 29, 2023
1 parent bf29c29 commit 14ee70d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions misc/metrics/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,25 @@ 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::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
1 change: 1 addition & 0 deletions protocols/relay/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
To achieve this, error handling was restructured:
- `libp2p::relay::outbound::stop::FatalUpgradeError` has been removed.
- `libp2p::relay::outbound::stop::{Error, ProtocolViolation}` have been introduced.
- Several variants of `libp2p::relay::Event` have been deprecated.

See [PR 4718](https://github.com/libp2p/rust-libp2p/pull/4718).
- Fix a rare race condition when making a reservation on a relay that could lead to a failed reservation.
Expand Down
20 changes: 20 additions & 0 deletions protocols/relay/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,19 @@ pub enum Event {
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 },
/// 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,
Expand All @@ -188,6 +194,9 @@ pub enum Event {
dst_peer_id: PeerId,
},
/// 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,
Expand All @@ -199,12 +208,18 @@ pub enum Event {
dst_peer_id: PeerId,
},
/// An outbound connect for an inbound cirucit 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,
Expand Down Expand Up @@ -455,6 +470,7 @@ impl NetworkBehaviour for Behaviour {
));
}
handler::Event::ReservationReqAcceptFailed { error } => {
#[allow(deprecated)]
self.queued_actions.push_back(ToSwarm::GenerateEvent(
Event::ReservationReqAcceptFailed {
src_peer_id: event_source,
Expand All @@ -470,6 +486,7 @@ impl NetworkBehaviour for Behaviour {
));
}
handler::Event::ReservationReqDenyFailed { error } => {
#[allow(deprecated)]
self.queued_actions.push_back(ToSwarm::GenerateEvent(
Event::ReservationReqDenyFailed {
src_peer_id: event_source,
Expand Down Expand Up @@ -592,6 +609,7 @@ 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,
Expand Down Expand Up @@ -639,6 +657,7 @@ impl NetworkBehaviour for Behaviour {
status,
}),
});
#[allow(deprecated)]
self.queued_actions.push_back(ToSwarm::GenerateEvent(
Event::CircuitReqOutboundConnectFailed {
src_peer_id,
Expand All @@ -664,6 +683,7 @@ 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,
Expand Down

0 comments on commit 14ee70d

Please sign in to comment.