aboutsummaryrefslogtreecommitdiff
path: root/p2p/src/peer
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-27 03:52:18 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-27 23:32:10 +0200
commitbcc6721257889f85f57af1b40351540585ffd41d (patch)
tree915adea7454fa91eafadfd9e7f9834a7cd0d9ebc /p2p/src/peer
parent7e4e25d9fbac403b0d46e8081baf00fb3865d56d (diff)
Remove redundant type aliases
Diffstat (limited to 'p2p/src/peer')
-rw-r--r--p2p/src/peer/mod.rs18
1 files changed, 8 insertions, 10 deletions
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<Peer>;
-
pub struct Peer {
/// Peer's ID
id: PeerID,
/// A weak pointer to `PeerPool`
- peer_pool: WeakPeerPool,
+ peer_pool: Weak<PeerPool>,
/// Holds the peer connection
conn: Conn<NetMsg>,
@@ -47,7 +45,7 @@ pub struct Peer {
protocol_ids: RwLock<Vec<ProtocolID>>,
/// `EventSys` responsible for sending events to the protocols.
- protocol_events: ArcEventSys<ProtocolID>,
+ protocol_events: Arc<EventSys<ProtocolID>>,
/// This channel is used to send a stop signal to the read loop.
stop_chan: (Sender<Result<()>>, Receiver<Result<()>>),
@@ -59,13 +57,13 @@ pub struct Peer {
impl Peer {
/// Creates a new peer
pub fn new(
- peer_pool: WeakPeerPool,
+ peer_pool: Weak<PeerPool>,
id: &PeerID,
conn: Conn<NetMsg>,
remote_endpoint: Endpoint,
conn_direction: ConnDirection,
ex: Executor,
- ) -> ArcPeer {
+ ) -> Arc<Peer> {
Arc::new(Peer {
id: id.clone(),
peer_pool,
@@ -228,7 +226,7 @@ impl Peer {
}
}
- fn peer_pool(&self) -> ArcPeerPool {
+ fn peer_pool(&self) -> Arc<PeerPool> {
self.peer_pool.upgrade().unwrap()
}
}