aboutsummaryrefslogtreecommitdiff
path: root/p2p/src/peer_pool.rs
diff options
context:
space:
mode:
authorhozan23 <hozan23@proton.me>2023-11-29 00:15:10 +0300
committerhozan23 <hozan23@proton.me>2023-11-29 00:15:10 +0300
commit2b032229e46293af92db798a36793c6b8b97baee (patch)
tree7b1304c952ff34604e9114d9d15c4687775c714b /p2p/src/peer_pool.rs
parent21e76cf87153c038909d95ff40d982b70003e2fa (diff)
p2p/protocol: improve the Protocol API
Diffstat (limited to 'p2p/src/peer_pool.rs')
-rw-r--r--p2p/src/peer_pool.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/p2p/src/peer_pool.rs b/p2p/src/peer_pool.rs
index dd7e669..ee9ebf9 100644
--- a/p2p/src/peer_pool.rs
+++ b/p2p/src/peer_pool.rs
@@ -189,8 +189,7 @@ impl PeerPool {
}
};
- self.task_group
- .spawn(peer.run(self.executor.clone()), on_disconnect);
+ self.task_group.spawn(peer.run(), on_disconnect);
info!("Add new peer {pid}, direction: {conn_direction}, endpoint: {endpoint}");
@@ -230,8 +229,9 @@ impl PeerPool {
/// Attach the core protocols.
async fn setup_protocols(&self) -> Result<()> {
- self.attach_protocol::<PingProtocol>(Box::new(PingProtocol::new))
- .await
+ let executor = self.executor.clone();
+ let c = move |peer| PingProtocol::new(peer, executor.clone());
+ self.attach_protocol::<PingProtocol>(Box::new(c)).await
}
/// Initiate a handshake with a connection.