diff options
author | hozan23 <hozan23@karyontech.net> | 2024-06-29 21:16:46 +0200 |
---|---|---|
committer | hozan23 <hozan23@karyontech.net> | 2024-06-29 21:16:46 +0200 |
commit | 5c0abab1b7bf0f2858c451d6f0efc7ca0e138fc6 (patch) | |
tree | 9d64a261ddd289560365b71f5d02d31df6c4a0ec /p2p/src/connector.rs | |
parent | bcc6721257889f85f57af1b40351540585ffd41d (diff) |
use shadown variables to name clones and place them between {} when spawning new tasks
Diffstat (limited to 'p2p/src/connector.rs')
-rw-r--r-- | p2p/src/connector.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/p2p/src/connector.rs b/p2p/src/connector.rs index a44daea..cfa661b 100644 --- a/p2p/src/connector.rs +++ b/p2p/src/connector.rs @@ -127,17 +127,18 @@ impl Connector { { let conn = self.connect(endpoint, peer_id).await?; - let selfc = self.clone(); let endpoint = endpoint.clone(); - let on_disconnect = |res| async move { - if let TaskResult::Completed(Err(err)) = res { - trace!("Outbound connection dropped: {err}"); + let on_disconnect = { + let this = self.clone(); + |res| async move { + if let TaskResult::Completed(Err(err)) = res { + trace!("Outbound connection dropped: {err}"); + } + this.monitor + .notify(ConnEvent::Disconnected(endpoint.clone())) + .await; + this.connection_slots.remove().await; } - selfc - .monitor - .notify(ConnEvent::Disconnected(endpoint.clone())) - .await; - selfc.connection_slots.remove().await; }; self.task_group.spawn(callback(conn), on_disconnect); |