add server.remove_good_host(..)

we'll use this later in gc jobs to clean up any hosts that have been
consistently down or whatever
main
Charlotte Som 2024-11-27 07:07:50 +02:00
parent a1ffb5cdc4
commit 35558748fa
1 changed files with 10 additions and 0 deletions

View File

@ -53,7 +53,17 @@ impl RelayServer {
let hosts_copy = hosts.iter().collect::<Vec<_>>(); let hosts_copy = hosts.iter().collect::<Vec<_>>();
let serialized_hosts = serde_ipld_dagcbor::to_vec(&hosts_copy)?; let serialized_hosts = serde_ipld_dagcbor::to_vec(&hosts_copy)?;
drop(hosts); drop(hosts);
self.db.insert("hosts", serialized_hosts)?;
Ok(())
}
pub async fn remove_good_host(&self, host: String) -> Result<()> {
tracing::debug!(%host, "dropping known-good host");
let mut hosts = self.known_good_hosts.lock().await;
hosts.remove(&host);
let hosts_copy = hosts.iter().collect::<Vec<_>>();
let serialized_hosts = serde_ipld_dagcbor::to_vec(&hosts_copy)?;
drop(hosts);
self.db.insert("hosts", serialized_hosts)?; self.db.insert("hosts", serialized_hosts)?;
Ok(()) Ok(())
} }