From bcc6721257889f85f57af1b40351540585ffd41d Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 27 Jun 2024 03:52:18 +0200 Subject: Remove redundant type aliases --- p2p/src/peer/mod.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'p2p/src/peer') diff --git a/p2p/src/peer/mod.rs b/p2p/src/peer/mod.rs index 0d42da3..2068789 100644 --- a/p2p/src/peer/mod.rs +++ b/p2p/src/peer/mod.rs @@ -2,7 +2,7 @@ mod peer_id; pub use peer_id::PeerID; -use std::sync::Arc; +use std::sync::{Arc, Weak}; use async_channel::{Receiver, Sender}; use bincode::{Decode, Encode}; @@ -11,7 +11,7 @@ use log::{error, trace}; use karyon_core::{ async_runtime::{lock::RwLock, Executor}, async_util::{select, Either, TaskGroup, TaskResult}, - event::{ArcEventSys, EventListener, EventSys}, + event::{EventListener, EventSys}, util::{decode, encode}, }; @@ -20,19 +20,17 @@ use karyon_net::{Conn, Endpoint}; use crate::{ conn_queue::ConnDirection, message::{NetMsg, NetMsgCmd, ProtocolMsg, ShutdownMsg}, - peer_pool::{ArcPeerPool, WeakPeerPool}, + peer_pool::PeerPool, protocol::{Protocol, ProtocolEvent, ProtocolID}, Config, Error, Result, }; -pub type ArcPeer = Arc; - pub struct Peer { /// Peer's ID id: PeerID, /// A weak pointer to `PeerPool` - peer_pool: WeakPeerPool, + peer_pool: Weak, /// Holds the peer connection conn: Conn, @@ -47,7 +45,7 @@ pub struct Peer { protocol_ids: RwLock>, /// `EventSys` responsible for sending events to the protocols. - protocol_events: ArcEventSys, + protocol_events: Arc>, /// This channel is used to send a stop signal to the read loop. stop_chan: (Sender>, Receiver>), @@ -59,13 +57,13 @@ pub struct Peer { impl Peer { /// Creates a new peer pub fn new( - peer_pool: WeakPeerPool, + peer_pool: Weak, id: &PeerID, conn: Conn, remote_endpoint: Endpoint, conn_direction: ConnDirection, ex: Executor, - ) -> ArcPeer { + ) -> Arc { Arc::new(Peer { id: id.clone(), peer_pool, @@ -228,7 +226,7 @@ impl Peer { } } - fn peer_pool(&self) -> ArcPeerPool { + fn peer_pool(&self) -> Arc { self.peer_pool.upgrade().unwrap() } } -- cgit v1.2.3