refine_session: actually delete greylist entries that fail the handshake

This commit is contained in:
draoi
2024-07-18 12:05:39 +02:00
parent 3359893c30
commit 1d8ab03f80

View File

@@ -268,7 +268,6 @@ impl GreylistRefinery {
match hosts.container.fetch_random_with_schemes(HostColor::Grey, &allowed_transports) {
Some((entry, _)) => {
let url = &entry.0;
let last_seen = &entry.1;
if let Err(e) = hosts.try_register(url.clone(), HostState::Refine) {
debug!(target: "net::refinery", "Unable to refine addr={}, err={}",
@@ -277,12 +276,15 @@ impl GreylistRefinery {
}
if !self.session().handshake_node(url.clone(), self.p2p().clone()).await {
hosts.container.remove_if_exists(HostColor::Grey, url);
debug!(
target: "net::refinery",
"Peer {} handshake failed. Removed from greylist", url,
);
hosts.greylist_host(url, *last_seen).unwrap();
// Free up this addr for future operations.
hosts.unregister(url);
continue
}