node: Fix logging on maintain connections

We were comparing the available peers with the target, so the comparison
would always succeed. We now compare it with the missing count, and use
debug logging since it's not something of concern yet.
This commit is contained in:
Alexis Sellier 2024-07-04 12:03:42 +02:00
parent fa19105f2f
commit 4b65c22305
No known key found for this signature in database
1 changed files with 9 additions and 8 deletions

View File

@ -2536,6 +2536,7 @@ where
return;
}
// Peers available to connect to.
let available = self
.available_peers()
.into_iter()
@ -2559,18 +2560,18 @@ where
// Only consider onion addresses if configured.
AddressType::Onion => self.config.onion.is_some(),
AddressType::Dns | AddressType::Ipv4 | AddressType::Ipv6 => true,
})
.take(wanted)
.collect::<Vec<_>>();
});
if available.len() < target {
log::warn!(
// Peers we are going to attempt connections to.
let connect = available.take(wanted).collect::<Vec<_>>();
if connect.len() < wanted {
log::debug!(
target: "service",
"Not enough available peers to connect to (available={}, target={target})",
available.len()
"Not enough available peers to connect to (available={}, wanted={wanted})",
connect.len()
);
}
for (id, ka) in available {
for (id, ka) in connect {
self.connect(id, ka.addr.clone());
}
}