From 2b032229e46293af92db798a36793c6b8b97baee Mon Sep 17 00:00:00 2001 From: hozan23 Date: Wed, 29 Nov 2023 00:15:10 +0300 Subject: p2p/protocol: improve the Protocol API --- p2p/src/peer/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'p2p/src/peer/mod.rs') diff --git a/p2p/src/peer/mod.rs b/p2p/src/peer/mod.rs index 6ed0dd8..37c0e2a 100644 --- a/p2p/src/peer/mod.rs +++ b/p2p/src/peer/mod.rs @@ -83,8 +83,8 @@ impl Peer { } /// Run the peer - pub async fn run(self: Arc, ex: GlobalExecutor) -> Result<()> { - self.start_protocols(ex).await; + pub async fn run(self: Arc) -> Result<()> { + self.start_protocols().await; self.read_loop().await } @@ -203,7 +203,7 @@ impl Peer { } /// Start running the protocols for this peer connection. - async fn start_protocols(self: &Arc, ex: GlobalExecutor) { + async fn start_protocols(self: &Arc) { for (protocol_id, constructor) in self.peer_pool().protocols.read().await.iter() { trace!("peer {} start protocol {protocol_id}", self.id); let protocol = constructor(self.clone()); @@ -223,8 +223,7 @@ impl Peer { } }; - self.task_group - .spawn(protocol.start(ex.clone()), on_failure); + self.task_group.spawn(protocol.start(), on_failure); } } -- cgit v1.2.3