diff --git a/src/lib.rs b/src/lib.rs index 34656bd..c540530 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,17 @@ impl RelayServer { let hosts_copy = hosts.iter().collect::>(); let serialized_hosts = serde_ipld_dagcbor::to_vec(&hosts_copy)?; 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::>(); + let serialized_hosts = serde_ipld_dagcbor::to_vec(&hosts_copy)?; + drop(hosts); self.db.insert("hosts", serialized_hosts)?; Ok(()) }