use crate::authenticated::{discovery::actors::tracker::Reservation, Mailbox};
use commonware_cryptography::PublicKey;
use commonware_runtime::{Sink, Stream};
use commonware_stream::encrypted::{Receiver, Sender};
use commonware_utils::channel::fallible::AsyncFallibleExt;
pub enum Message<O: Sink, I: Stream, P: PublicKey> {
Spawn {
peer: P,
connection: (Sender<O>, Receiver<I>),
reservation: Reservation<P>,
},
}
impl<P: PublicKey, O: Sink, I: Stream> Mailbox<Message<O, I, P>> {
pub async fn spawn(
&mut self,
connection: (Sender<O>, Receiver<I>),
reservation: Reservation<P>,
) {
self.0
.send_lossy(Message::Spawn {
peer: reservation.metadata().public_key().clone(),
connection,
reservation,
})
.await;
}
}