aboutsummaryrefslogtreecommitdiff
path: root/p2p/src/peer
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-29 21:16:46 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-29 21:16:46 +0200
commit5c0abab1b7bf0f2858c451d6f0efc7ca0e138fc6 (patch)
tree9d64a261ddd289560365b71f5d02d31df6c4a0ec /p2p/src/peer
parentbcc6721257889f85f57af1b40351540585ffd41d (diff)
use shadown variables to name clones and place them between {} when spawning new tasks
Diffstat (limited to 'p2p/src/peer')
-rw-r--r--p2p/src/peer/mod.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/p2p/src/peer/mod.rs b/p2p/src/peer/mod.rs
index 2068789..6903294 100644
--- a/p2p/src/peer/mod.rs
+++ b/p2p/src/peer/mod.rs
@@ -209,16 +209,17 @@ impl Peer {
self.protocol_ids.write().await.push(protocol_id.clone());
- let selfc = self.clone();
- let proto_idc = protocol_id.clone();
-
- let on_failure = |result: TaskResult<Result<()>>| async move {
- if let TaskResult::Completed(res) = result {
- if res.is_err() {
- error!("protocol {} stopped", proto_idc);
+ let on_failure = {
+ let this = self.clone();
+ let protocol_id = protocol_id.clone();
+ |result: TaskResult<Result<()>>| async move {
+ if let TaskResult::Completed(res) = result {
+ if res.is_err() {
+ error!("protocol {} stopped", protocol_id);
+ }
+ // Send a stop signal to read loop
+ let _ = this.stop_chan.0.try_send(res);
}
- // Send a stop signal to read loop
- let _ = selfc.stop_chan.0.try_send(res);
}
};