From 290bf24c1c310a40c937fc90e4460869eb810a5a Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 17 Jan 2023 14:19:46 +1100 Subject: [PATCH] Revert "refactor(relay): introduce `Handler::new` functions (#3326)" This reverts commit aed5363135b06237befeccca95fef1e10ffc232c. --- protocols/relay/src/behaviour/handler.rs | 30 +++++++++----------- protocols/relay/src/priv_client/handler.rs | 32 ++++++++-------------- 2 files changed, 25 insertions(+), 37 deletions(-) diff --git a/protocols/relay/src/behaviour/handler.rs b/protocols/relay/src/behaviour/handler.rs index 20b7a01af14..120e980c001 100644 --- a/protocols/relay/src/behaviour/handler.rs +++ b/protocols/relay/src/behaviour/handler.rs @@ -351,7 +351,19 @@ impl IntoConnectionHandler for Prototype { // Deny all substreams on relayed connection. Either::Right(dummy::ConnectionHandler) } else { - Either::Left(Handler::new(self.config, endpoint.clone())) + Either::Left(Handler { + endpoint: endpoint.clone(), + config: self.config, + queued_events: Default::default(), + pending_error: Default::default(), + reservation_request_future: Default::default(), + circuit_accept_futures: Default::default(), + circuit_deny_futures: Default::default(), + alive_lend_out_substreams: Default::default(), + circuits: Default::default(), + active_reservation: Default::default(), + keep_alive: KeepAlive::Yes, + }) } } @@ -420,22 +432,6 @@ pub struct Handler { } impl Handler { - fn new(config: Config, endpoint: ConnectedPoint) -> Handler { - Handler { - endpoint, - config, - queued_events: Default::default(), - pending_error: Default::default(), - reservation_request_future: Default::default(), - circuit_accept_futures: Default::default(), - circuit_deny_futures: Default::default(), - alive_lend_out_substreams: Default::default(), - circuits: Default::default(), - active_reservation: Default::default(), - keep_alive: KeepAlive::Yes, - } - } - fn on_fully_negotiated_inbound( &mut self, FullyNegotiatedInbound { diff --git a/protocols/relay/src/priv_client/handler.rs b/protocols/relay/src/priv_client/handler.rs index 922a767cf45..c9f7c18adbb 100644 --- a/protocols/relay/src/priv_client/handler.rs +++ b/protocols/relay/src/priv_client/handler.rs @@ -141,11 +141,18 @@ impl IntoConnectionHandler for Prototype { // Deny all substreams on relayed connection. Either::Right(dummy::ConnectionHandler) } else { - let mut handler = Handler::new( - self.local_peer_id, - *remote_peer_id, - endpoint.get_remote_address().clone(), - ); + let mut handler = Handler { + remote_peer_id: *remote_peer_id, + remote_addr: endpoint.get_remote_address().clone(), + local_peer_id: self.local_peer_id, + queued_events: Default::default(), + pending_error: Default::default(), + reservation: Reservation::None, + alive_lend_out_substreams: Default::default(), + circuit_deny_futs: Default::default(), + send_error_futs: Default::default(), + keep_alive: KeepAlive::Yes, + }; if let Some(event) = self.initial_in { handler.on_behaviour_event(event) @@ -206,21 +213,6 @@ pub struct Handler { } impl Handler { - fn new(local_peer_id: PeerId, remote_peer_id: PeerId, remote_addr: Multiaddr) -> Self { - Self { - local_peer_id, - remote_peer_id, - remote_addr, - queued_events: Default::default(), - pending_error: Default::default(), - reservation: Reservation::None, - alive_lend_out_substreams: Default::default(), - circuit_deny_futs: Default::default(), - send_error_futs: Default::default(), - keep_alive: KeepAlive::Yes, - } - } - fn on_fully_negotiated_inbound( &mut self, FullyNegotiatedInbound {