diff options
author | hozan23 <hozan23@karyontech.net> | 2024-06-27 03:52:18 +0200 |
---|---|---|
committer | hozan23 <hozan23@karyontech.net> | 2024-06-27 23:32:10 +0200 |
commit | bcc6721257889f85f57af1b40351540585ffd41d (patch) | |
tree | 915adea7454fa91eafadfd9e7f9834a7cd0d9ebc /p2p/src/backend.rs | |
parent | 7e4e25d9fbac403b0d46e8081baf00fb3865d56d (diff) |
Remove redundant type aliases
Diffstat (limited to 'p2p/src/backend.rs')
-rw-r--r-- | p2p/src/backend.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/p2p/src/backend.rs b/p2p/src/backend.rs index f21d70b..4d24be6 100644 --- a/p2p/src/backend.rs +++ b/p2p/src/backend.rs @@ -6,17 +6,10 @@ use karyon_core::{async_runtime::Executor, crypto::KeyPair}; use karyon_net::Endpoint; use crate::{ - config::Config, - conn_queue::ConnQueue, - discovery::{ArcDiscovery, Discovery}, - monitor::Monitor, - peer_pool::PeerPool, - protocol::{ArcProtocol, Protocol}, - ArcPeer, PeerID, Result, + config::Config, conn_queue::ConnQueue, discovery::Discovery, monitor::Monitor, peer::Peer, + peer_pool::PeerPool, protocol::Protocol, PeerID, Result, }; -pub type ArcBackend = Arc<Backend>; - /// Backend serves as the central entry point for initiating and managing /// the P2P network. pub struct Backend { @@ -33,7 +26,7 @@ pub struct Backend { monitor: Arc<Monitor>, /// Discovery instance. - discovery: ArcDiscovery, + discovery: Arc<Discovery>, /// PeerPool instance. peer_pool: Arc<PeerPool>, @@ -41,7 +34,7 @@ pub struct Backend { impl Backend { /// Creates a new Backend. - pub fn new(key_pair: &KeyPair, config: Config, ex: Executor) -> ArcBackend { + pub fn new(key_pair: &KeyPair, config: Config, ex: Executor) -> Arc<Backend> { let config = Arc::new(config); let monitor = Arc::new(Monitor::new(config.clone())); let conn_queue = ConnQueue::new(); @@ -87,7 +80,7 @@ impl Backend { /// Attach a custom protocol to the network pub async fn attach_protocol<P: Protocol>( &self, - c: impl Fn(ArcPeer) -> ArcProtocol + Send + Sync + 'static, + c: impl Fn(Arc<Peer>) -> Arc<dyn Protocol> + Send + Sync + 'static, ) -> Result<()> { self.peer_pool.attach_protocol::<P>(Box::new(c)).await } |