mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
refine_session: use remove_if_exists() method to delete entry when refinery fails
There's no need to acquire the write lock in the refinery when we can just use one of the hosts methods.
This commit is contained in:
@@ -645,7 +645,7 @@ impl HostContainer {
|
||||
}
|
||||
|
||||
/// Remove an entry from a hostlist if it exists.
|
||||
async fn remove_if_exists(&self, color: HostColor, addr: &Url) {
|
||||
pub async fn remove_if_exists(&self, color: HostColor, addr: &Url) {
|
||||
let color_code = color.clone() as usize;
|
||||
let mut list = self.hostlists[color_code].write().await;
|
||||
if let Some(position) = list.iter().position(|(u, _)| u == addr) {
|
||||
|
||||
@@ -271,18 +271,7 @@ impl GreylistRefinery {
|
||||
}
|
||||
|
||||
if !self.session().handshake_node(url.clone(), p2p.clone()).await {
|
||||
{
|
||||
let mut greylist =
|
||||
hosts.container.hostlists[HostColor::Grey as usize].write().await;
|
||||
|
||||
let position = hosts
|
||||
.container
|
||||
.get_index_at_addr(HostColor::Grey as usize, url.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
greylist.remove(position);
|
||||
}
|
||||
hosts.container.remove_if_exists(HostColor::Grey, url).await;
|
||||
|
||||
debug!(
|
||||
target: "net::refinery",
|
||||
|
||||
Reference in New Issue
Block a user