Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 39 additions & 35 deletions src/ws_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl WsConnection {
let (message_tx, message_rx) = mpsc::channel::<String>(128);
Self {
authenticated: false,
fast_ws: Default::default(),
fast_ws: Arc::new(AtomicBool::new(true)),
subscribed_topics: Default::default(),
challenge: Some(Challenge {
// Set nonce store for authentication and the send message immediately to the user
Expand Down Expand Up @@ -316,42 +316,46 @@ impl WsConnection {
self.send_message(WsMessage::auth().set_message("Authenticated"))?;
self.authenticated = true;
self.challenge.take();

// Load the connection priority from IF stake (async)
tokio::spawn({
let fast_ws = Arc::clone(&self.fast_ws);
let pubkey = self.pubkey;
async move {
let is_fast_ws = determine_fast_ws(&pubkey).await;
if let Err(ref err) = is_fast_ws {
log::error!(
"{}: Failed to determine if fast ws: {err:?}",
pubkey.to_string()
);
shared_state
.metrics
.ws_connections
.with_label_values(&["false"])
.inc();
} else {
log::info!(
target: "ws",

"{}: Is fast ws: {is_fast_ws:?}",
pubkey.to_string()
);
let is_fast_ws = is_fast_ws.unwrap();
shared_state
.metrics
.ws_connections
.with_label_values(&[&is_fast_ws.to_string()])
.inc();
fast_ws.store(is_fast_ws, std::sync::atomic::Ordering::Relaxed);
}
}
});
shared_state
.metrics
.ws_connections
.with_label_values(&[&self.is_fast().to_string()])
.inc();

Ok(())
// Load the connection priority from IF stake (async)
// tokio::spawn({
// let fast_ws = Arc::clone(&self.fast_ws);
// let pubkey = self.pubkey;
// async move {
// let is_fast_ws = determine_fast_ws(&pubkey).await;
// if let Err(ref err) = is_fast_ws {
// log::error!(
// "{}: Failed to determine if fast ws: {err:?}",
// pubkey.to_string()
// );
// shared_state
// .metrics
// .ws_connections
// .with_label_values(&["false"])
// .inc();
// } else {
// log::info!(
// target: "ws",

// "{}: Is fast ws: {is_fast_ws:?}",
// pubkey.to_string()
// );
// let is_fast_ws = is_fast_ws.unwrap();
// shared_state
// .metrics
// .ws_connections
// .with_label_values(&[&is_fast_ws.to_string()])
// .inc();
// fast_ws.store(is_fast_ws, std::sync::atomic::Ordering::Relaxed);
// }
// }
// });
}
Err(e) => {
self.send_message(
Expand Down
Loading