mirror of
https://github.com/stakwork/sphinx-key.git
synced 2026-02-23 08:34:29 +01:00
broker, sphinx-key: remove variable session id
This commit is contained in:
@@ -6,7 +6,7 @@ use std::collections::HashMap;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Connections {
|
||||
pub pubkey: Option<String>,
|
||||
pub clients: HashMap<String, String>,
|
||||
pub clients: HashMap<String, bool>,
|
||||
pub current: String,
|
||||
}
|
||||
|
||||
@@ -25,12 +25,10 @@ impl Connections {
|
||||
self.current = cid;
|
||||
}
|
||||
pub fn add_client(&mut self, cid: &str) {
|
||||
let (value, key) = cid.split_once("_").expect("id is missing _ delimeter");
|
||||
self.clients.insert(value.to_string(), key.to_string());
|
||||
self.clients.insert(cid.to_string(), false);
|
||||
}
|
||||
pub fn remove_client(&mut self, cid: &str) {
|
||||
let (value, _key) = cid.split_once("_").expect("id is missing _ delimeter");
|
||||
self.clients.remove(value);
|
||||
self.clients.remove(cid);
|
||||
}
|
||||
pub fn client_action(&mut self, cid: &str, connected: bool) {
|
||||
if connected {
|
||||
|
||||
@@ -177,13 +177,12 @@ fn pub_and_wait(
|
||||
let mut rep = pub_timeout(¤t, &msg.topic, &msg.message, &msg_rx, link_tx);
|
||||
// If that failed, try looking for some other signer
|
||||
if rep.is_none() {
|
||||
for (id, session) in client_list.iter() {
|
||||
let cid = format!("{}_{}", id, session);
|
||||
for cid in client_list.keys() {
|
||||
rep = pub_timeout(&cid, &msg.topic, &msg.message, &msg_rx, link_tx);
|
||||
if rep.is_some() {
|
||||
let mut cs = conns_.lock().unwrap();
|
||||
log::debug!("got the list lock!");
|
||||
cs.set_current(cid);
|
||||
cs.set_current(cid.to_string());
|
||||
drop(cs);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ fn main() -> Result<()> {
|
||||
fn make_and_launch_client(
|
||||
config: Config,
|
||||
seed: [u8; 32],
|
||||
id: String,
|
||||
client_id: String,
|
||||
policy: &Policy,
|
||||
velocity: &Option<Velocity>,
|
||||
led_tx: mpsc::Sender<Status>,
|
||||
@@ -166,7 +166,6 @@ fn make_and_launch_client(
|
||||
let token = ctrlr.make_auth_token().expect("couldnt make auth token");
|
||||
log::info!("PUBKEY {} TOKEN {}", &pubkey_str, &token);
|
||||
|
||||
let client_id = format!("{}_{}", id, random_word(8));
|
||||
let mqtt_client =
|
||||
conn::mqtt::make_client(&config.broker, &client_id, &pubkey_str, &token, tx.clone())?;
|
||||
// let mqtt_client = conn::mqtt::start_listening(mqtt, connection, tx)?;
|
||||
|
||||
Reference in New Issue
Block a user