fedimint_server/net/
p2p_connector.rs1mod iroh;
5mod tls;
6
7use std::sync::Arc;
8
9use async_trait::async_trait;
10use fedimint_core::PeerId;
11use fedimint_server_core::dashboard_ui::ConnectionType;
12
13pub use self::iroh::*;
14pub use self::tls::*;
15use crate::net::p2p_connection::DynP2PConnection;
16
17pub type DynP2PConnector<M> = Arc<dyn IP2PConnector<M>>;
18
19#[async_trait]
23pub trait IP2PConnector<M>: Send + Sync + 'static {
24 fn peers(&self) -> Vec<PeerId>;
25
26 async fn connect(&self, peer: PeerId) -> anyhow::Result<DynP2PConnection<M>>;
27
28 async fn accept(&self) -> anyhow::Result<(PeerId, DynP2PConnection<M>)>;
29
30 async fn connection_type(&self, peer: PeerId) -> ConnectionType;
32
33 fn into_dyn(self) -> DynP2PConnector<M>
34 where
35 Self: Sized,
36 {
37 Arc::new(self)
38 }
39}