From 3a84c141787d2206db1ace365fa1b19082d9f00a Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 11 Jan 2023 16:13:16 +1100 Subject: [PATCH 1/3] Use single quotes to avoid running commands --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ce4fc5fdea..a25fdf3c4e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -299,10 +299,10 @@ jobs: - name: Check PR title length run: | - title="${{ github.event.pull_request.title }}" + title='${{ github.event.pull_request.title }}' title_length=${#title} if [ $title_length -gt 72 ] then echo "PR title is too long (greater than 72 characters)" exit 1 - fi \ No newline at end of file + fi From 458aa533d9489aa374658bdba808f45446d4925d Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 13 Jan 2023 11:47:28 +1100 Subject: [PATCH 2/3] Use intermediary variable --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a25fdf3c4e0..c8725c7a332 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -298,9 +298,10 @@ jobs: require_scope: false - name: Check PR title length + env: + TITLE: ${{ github.event.pull_request.title }} run: | - title='${{ github.event.pull_request.title }}' - title_length=${#title} + title_length=${#TITLE} if [ $title_length -gt 72 ] then echo "PR title is too long (greater than 72 characters)" From 79c84fbad8bf34ba43f606e1ad084a7d9ba537ec Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 16 Jan 2023 12:16:42 +1100 Subject: [PATCH 3/3] Introduce Handler::new --- protocols/relay/src/behaviour/handler.rs | 30 +++++++++++--------- protocols/relay/src/priv_client/handler.rs | 32 ++++++++++++++-------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/protocols/relay/src/behaviour/handler.rs b/protocols/relay/src/behaviour/handler.rs index 120e980c001..20b7a01af14 100644 --- a/protocols/relay/src/behaviour/handler.rs +++ b/protocols/relay/src/behaviour/handler.rs @@ -351,19 +351,7 @@ impl IntoConnectionHandler for Prototype { // Deny all substreams on relayed connection. Either::Right(dummy::ConnectionHandler) } else { - 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, - }) + Either::Left(Handler::new(self.config, endpoint.clone())) } } @@ -432,6 +420,22 @@ 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 c9f7c18adbb..922a767cf45 100644 --- a/protocols/relay/src/priv_client/handler.rs +++ b/protocols/relay/src/priv_client/handler.rs @@ -141,18 +141,11 @@ impl IntoConnectionHandler for Prototype { // Deny all substreams on relayed connection. Either::Right(dummy::ConnectionHandler) } else { - 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, - }; + let mut handler = Handler::new( + self.local_peer_id, + *remote_peer_id, + endpoint.get_remote_address().clone(), + ); if let Some(event) = self.initial_in { handler.on_behaviour_event(event) @@ -213,6 +206,21 @@ 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 {