MCPcopy Create free account
hub / github.com/Recordscript/recordscript / update_latency

Method update_latency

libs/hbb_common/src/config.rs:746–765  ·  view source on GitHub ↗
(host: &str, latency: i64)

Source from the content-addressed store, hash-verified

744 }
745
746 pub fn update_latency(host: &str, latency: i64) {
747 ONLINE.lock().unwrap().insert(host.to_owned(), latency);
748 let mut host = "".to_owned();
749 let mut delay = i64::MAX;
750 for (tmp_host, tmp_delay) in ONLINE.lock().unwrap().iter() {
751 if tmp_delay > &0 && tmp_delay < &delay {
752 delay = *tmp_delay;
753 host = tmp_host.to_string();
754 }
755 }
756 if !host.is_empty() {
757 let mut config = CONFIG2.write().unwrap();
758 if host != config.rendezvous_server {
759 log::debug!("Update rendezvous_server in config to {}", host);
760 log::debug!("{:?}", *ONLINE.lock().unwrap());
761 config.rendezvous_server = host;
762 config.store();
763 }
764 }
765 }
766
767 pub fn set_id(id: &str) {
768 let mut config = CONFIG.write().unwrap();

Callers

nothing calls this directly

Calls 5

iterMethod · 0.80
to_stringMethod · 0.80
is_emptyMethod · 0.80
writeMethod · 0.80
storeMethod · 0.80

Tested by

no test coverage detected