diff --git a/broker/src/conn.rs b/broker/src/conn.rs index 12ed95c..a58f283 100644 --- a/broker/src/conn.rs +++ b/broker/src/conn.rs @@ -52,6 +52,7 @@ pub struct ChannelRequest { pub message: Vec, pub reply_tx: oneshot::Sender, pub cid: Option, // if it exists, only try the one client + pub signer_type: Option, // if it exists, only try clients of these types } impl ChannelRequest { pub fn new(topic: &str, message: Vec) -> (Self, oneshot::Receiver) { @@ -61,6 +62,7 @@ impl ChannelRequest { message, reply_tx, cid: None, + signer_type: None, }; (cr, reply_rx) } @@ -75,6 +77,7 @@ impl ChannelRequest { message, reply_tx, cid: None, + signer_type: None, }; let _ = sender.send(req).await; let reply = reply_rx.await?; @@ -92,13 +95,14 @@ impl ChannelRequest { message, reply_tx, cid: Some(cid.to_string()), + signer_type: None, }; let _ = sender.send(req).await; let reply = reply_rx.await?; Ok(reply.reply) } pub fn for_cid(&mut self, cid: &str) { - self.cid = Some(cid.to_string()) + self.cid = Some(cid.to_string()); } pub fn new_for( cid: &str, @@ -109,6 +113,18 @@ impl ChannelRequest { cr.for_cid(cid); (cr, reply_rx) } + pub fn for_type(&mut self, signer_type: SignerType) { + self.signer_type = Some(signer_type); + } + pub fn new_for_type( + signer_type: SignerType, + topic: &str, + message: Vec, + ) -> (Self, oneshot::Receiver) { + let (mut cr, reply_rx) = ChannelRequest::new(topic, message); + cr.for_type(signer_type); + (cr, reply_rx) + } } // mpsc reply