use crate::authenticated::{lookup::actors::tracker::Reservation, Mailbox}; use commonware_cryptography::PublicKey; use commonware_runtime::{Clock, Metrics, Sink, Spawner, Stream}; use commonware_stream::public_key::Connection; /// Messages that can be processed by the spawner actor. pub enum Message { /// Notify the spawner to create a new task for the given peer. Spawn { /// The peer's public key. peer: P, /// The connection to the peer. connection: Connection, /// The reservation for the peer. reservation: Reservation, }, } impl Mailbox> { /// Send a message to the actor to spawn a new task for the given peer. pub async fn spawn(&mut self, connection: Connection, reservation: Reservation) { self.send(Message::Spawn { peer: reservation.metadata().public_key().clone(), connection, reservation, }) .await .unwrap(); } }