1pub mod api_announcement;
2pub mod auth;
3pub mod guardian_metadata;
4pub mod iroh;
5
6#[cfg(not(target_family = "wasm"))]
7pub mod fake;
8
9pub const STANDARD_FEDIMINT_P2P_PORT: u16 = 8173;
10
11use std::sync::Arc;
12
13use async_trait::async_trait;
14use fedimint_core::PeerId;
15
16pub type DynP2PConnections<M> = Arc<dyn IP2PConnections<M>>;
17
18#[async_trait]
20pub trait IP2PConnections<M>: Send + Sync + 'static {
21 fn send(&self, recipient: Recipient, msg: M);
23
24 async fn receive(&self) -> Option<(PeerId, M)>;
26
27 async fn receive_from_peer(&self, peer: PeerId) -> Option<M>;
29
30 fn into_dyn(self) -> DynP2PConnections<M>
32 where
33 Self: Sized,
34 {
35 Arc::new(self)
36 }
37}
38
39#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum Recipient {
42 Everyone,
43 Peer(PeerId),
44}