use std::sync::Arc;
use async_trait::async_trait;
use fedimint_core::PeerId;
#[cfg(not(target_family = "wasm"))]
pub mod fake;
pub type DynP2PConnections<M> = Arc<dyn IP2PConnections<M>>;
#[async_trait]
pub trait IP2PConnections<M>: Send + Sync + 'static {
fn send(&self, recipient: Recipient, msg: M);
async fn receive(&self) -> Option<(PeerId, M)>;
async fn receive_from_peer(&self, peer: PeerId) -> Option<M>;
fn into_dyn(self) -> DynP2PConnections<M>
where
Self: Sized,
{
Arc::new(self)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Recipient {
Everyone,
Peer(PeerId),
}