mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-11-29 23:46:35 -05:00
clippy work
This commit is contained in:
parent
8a1260ed48
commit
6438a64fc7
62 changed files with 414 additions and 310 deletions
|
|
@ -223,7 +223,7 @@ impl BucketEntryInner {
|
|||
// Lower timestamp to the front, recent or no timestamp is at the end
|
||||
if let Some(e1_ts) = &e1.peer_stats.rpc_stats.first_consecutive_seen_ts {
|
||||
if let Some(e2_ts) = &e2.peer_stats.rpc_stats.first_consecutive_seen_ts {
|
||||
e1_ts.cmp(&e2_ts)
|
||||
e1_ts.cmp(e2_ts)
|
||||
} else {
|
||||
std::cmp::Ordering::Less
|
||||
}
|
||||
|
|
@ -437,7 +437,7 @@ impl BucketEntryInner {
|
|||
|
||||
// Clears the table of last connections except the most recent one
|
||||
pub fn clear_last_connections_except_latest(&mut self) {
|
||||
if self.last_connections.len() == 0 {
|
||||
if self.last_connections.is_empty() {
|
||||
// No last_connections
|
||||
return;
|
||||
}
|
||||
|
|
@ -454,7 +454,7 @@ impl BucketEntryInner {
|
|||
let Some(most_recent_connection) = most_recent_connection else {
|
||||
return;
|
||||
};
|
||||
for (k, _) in &self.last_connections {
|
||||
for k in self.last_connections.keys() {
|
||||
if k != most_recent_connection {
|
||||
dead_keys.push(k.clone());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -388,11 +388,15 @@ impl RoutingTable {
|
|||
}
|
||||
|
||||
// Caches valid, load saved routing table
|
||||
let Some(serialized_bucket_map): Option<SerializedBucketMap> = db.load_json(0, SERIALIZED_BUCKET_MAP).await? else {
|
||||
let Some(serialized_bucket_map): Option<SerializedBucketMap> =
|
||||
db.load_json(0, SERIALIZED_BUCKET_MAP).await?
|
||||
else {
|
||||
log_rtab!(debug "no bucket map in saved routing table");
|
||||
return Ok(());
|
||||
};
|
||||
let Some(all_entry_bytes): Option<SerializedBuckets> = db.load_json(0, ALL_ENTRY_BYTES).await? else {
|
||||
let Some(all_entry_bytes): Option<SerializedBuckets> =
|
||||
db.load_json(0, ALL_ENTRY_BYTES).await?
|
||||
else {
|
||||
log_rtab!(debug "no all_entry_bytes in saved routing table");
|
||||
return Ok(());
|
||||
};
|
||||
|
|
|
|||
|
|
@ -258,11 +258,9 @@ impl RoutingDomainEditor {
|
|||
}
|
||||
}
|
||||
// Clear the routespecstore cache if our PublicInternet dial info has changed
|
||||
if changed {
|
||||
if self.routing_domain == RoutingDomain::PublicInternet {
|
||||
let rss = self.routing_table.route_spec_store();
|
||||
rss.reset();
|
||||
}
|
||||
if changed && self.routing_domain == RoutingDomain::PublicInternet {
|
||||
let rss = self.routing_table.route_spec_store();
|
||||
rss.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ pub trait RoutingDomainDetail {
|
|||
peer_b: &PeerInfo,
|
||||
dial_info_filter: DialInfoFilter,
|
||||
sequencing: Sequencing,
|
||||
dif_sort: Option<Arc<dyn Fn(&DialInfoDetail, &DialInfoDetail) -> core::cmp::Ordering>>,
|
||||
dif_sort: Option<Arc<DialInfoDetailSort>>,
|
||||
) -> ContactMethod;
|
||||
}
|
||||
|
||||
|
|
@ -301,12 +301,10 @@ fn first_filtered_dial_info_detail_between_nodes(
|
|||
} else {
|
||||
Some(Box::new(move |a,b| { DialInfoDetail::ordered_sequencing_sort(a,b) }))
|
||||
}
|
||||
} else if let Some(dif_sort) = dif_sort {
|
||||
Some(Box::new(move |a,b| { dif_sort(a,b) }))
|
||||
} else {
|
||||
if let Some(dif_sort) = dif_sort {
|
||||
Some(Box::new(move |a,b| { dif_sort(a,b) }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
None
|
||||
};
|
||||
|
||||
// If the filter is dead then we won't be able to connect
|
||||
|
|
@ -336,7 +334,7 @@ impl RoutingDomainDetail for PublicInternetRoutingDomainDetail {
|
|||
peer_b: &PeerInfo,
|
||||
dial_info_filter: DialInfoFilter,
|
||||
sequencing: Sequencing,
|
||||
dif_sort: Option<Arc<dyn Fn(&DialInfoDetail, &DialInfoDetail) -> core::cmp::Ordering>>,
|
||||
dif_sort: Option<Arc<DialInfoDetailSort>>,
|
||||
) -> ContactMethod {
|
||||
// Get the nodeinfos for convenience
|
||||
let node_a = peer_a.signed_node_info().node_info();
|
||||
|
|
@ -554,7 +552,7 @@ impl RoutingDomainDetail for LocalNetworkRoutingDomainDetail {
|
|||
&mut self.common
|
||||
}
|
||||
fn can_contain_address(&self, address: Address) -> bool {
|
||||
let ip = address.to_ip_addr();
|
||||
let ip = address.ip_addr();
|
||||
for localnet in &self.local_networks {
|
||||
if ipaddr_in_network(ip, localnet.0, localnet.1) {
|
||||
return true;
|
||||
|
|
@ -570,7 +568,7 @@ impl RoutingDomainDetail for LocalNetworkRoutingDomainDetail {
|
|||
peer_b: &PeerInfo,
|
||||
dial_info_filter: DialInfoFilter,
|
||||
sequencing: Sequencing,
|
||||
dif_sort: Option<Arc<dyn Fn(&DialInfoDetail, &DialInfoDetail) -> core::cmp::Ordering>>,
|
||||
dif_sort: Option<Arc<DialInfoDetailSort>>,
|
||||
) -> ContactMethod {
|
||||
// Scope the filter down to protocols node A can do outbound
|
||||
let dial_info_filter = dial_info_filter.filtered(
|
||||
|
|
@ -596,12 +594,10 @@ impl RoutingDomainDetail for LocalNetworkRoutingDomainDetail {
|
|||
} else {
|
||||
Some(Box::new(move |a,b| { DialInfoDetail::ordered_sequencing_sort(a,b) }))
|
||||
}
|
||||
} else if let Some(dif_sort) = dif_sort {
|
||||
Some(Box::new(move |a,b| { dif_sort(a,b) }))
|
||||
} else {
|
||||
if let Some(dif_sort) = dif_sort {
|
||||
Some(Box::new(move |a,b| { dif_sort(a,b) }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
None
|
||||
};
|
||||
|
||||
// If the filter is dead then we won't be able to connect
|
||||
|
|
|
|||
|
|
@ -550,10 +550,9 @@ impl RoutingTableInner {
|
|||
}
|
||||
|
||||
// If we don't have node status for this node, then we should ping it to get some node status
|
||||
if e.has_node_info(routing_domain.into()) {
|
||||
if e.node_status(routing_domain).is_none() {
|
||||
return true;
|
||||
}
|
||||
if e.has_node_info(routing_domain.into()) && e.node_status(routing_domain).is_none()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// If this entry needs a ping because this node hasn't seen our latest node info, then do it
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ impl RoutingTable {
|
|||
}
|
||||
}
|
||||
}
|
||||
if bootstrap_dialinfos.len() > 0 {
|
||||
if !bootstrap_dialinfos.is_empty() {
|
||||
return self
|
||||
.direct_bootstrap_task_routine(stop_token, bootstrap_dialinfos)
|
||||
.await;
|
||||
|
|
|
|||
|
|
@ -78,8 +78,11 @@ impl RoutingTable {
|
|||
|
||||
// Save up to N unpublished routes and test them
|
||||
let background_safety_route_count = self.get_background_safety_route_count();
|
||||
for x in 0..(usize::min(background_safety_route_count, unpublished_routes.len())) {
|
||||
must_test_routes.push(unpublished_routes[x].0);
|
||||
for unpublished_route in unpublished_routes.iter().take(usize::min(
|
||||
background_safety_route_count,
|
||||
unpublished_routes.len(),
|
||||
)) {
|
||||
must_test_routes.push(unpublished_route.0);
|
||||
}
|
||||
|
||||
// Kill off all but N unpublished routes rather than testing them
|
||||
|
|
@ -225,9 +228,9 @@ impl RoutingTable {
|
|||
let remote_routes_needing_testing = rss.list_remote_routes(|k, v| {
|
||||
let stats = v.get_stats();
|
||||
if stats.needs_testing(cur_ts) {
|
||||
return Some(*k);
|
||||
Some(*k)
|
||||
} else {
|
||||
return None;
|
||||
None
|
||||
}
|
||||
});
|
||||
if !remote_routes_needing_testing.is_empty() {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ impl MatchesDialInfoFilter for DialInfoDetail {
|
|||
}
|
||||
}
|
||||
|
||||
pub type DialInfoDetailSort = dyn Fn(&DialInfoDetail, &DialInfoDetail) -> core::cmp::Ordering;
|
||||
|
||||
impl DialInfoDetail {
|
||||
pub fn ordered_sequencing_sort(a: &DialInfoDetail, b: &DialInfoDetail) -> core::cmp::Ordering {
|
||||
let c = DialInfo::ordered_sequencing_sort(&a.dial_info, &b.dial_info);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use super::*;
|
||||
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
#[allow(clippy::derived_hash_with_manual_eq)]
|
||||
#[derive(Debug, PartialOrd, Ord, Hash, EnumSetType, Serialize, Deserialize)]
|
||||
#[enumset(repr = "u8")]
|
||||
pub enum Direction {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ pub struct PeerInfo {
|
|||
|
||||
impl PeerInfo {
|
||||
pub fn new(node_ids: TypedKeyGroup, signed_node_info: SignedNodeInfo) -> Self {
|
||||
assert!(node_ids.len() > 0 && node_ids.len() <= MAX_CRYPTO_KINDS);
|
||||
assert!(!node_ids.is_empty() && node_ids.len() <= MAX_CRYPTO_KINDS);
|
||||
Self {
|
||||
node_ids,
|
||||
signed_node_info,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use super::*;
|
||||
|
||||
// Routing domain here is listed in order of preference, keep in order
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
#[allow(clippy::derived_hash_with_manual_eq)]
|
||||
#[derive(Debug, Ord, PartialOrd, Hash, EnumSetType, Serialize, Deserialize)]
|
||||
#[enumset(repr = "u8")]
|
||||
pub enum RoutingDomain {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ impl SignedDirectNodeInfo {
|
|||
// Verify the signatures that we can
|
||||
let validated_node_ids =
|
||||
crypto.verify_signatures(node_ids, &node_info_bytes, &self.signatures)?;
|
||||
if validated_node_ids.len() == 0 {
|
||||
if validated_node_ids.is_empty() {
|
||||
apibail_generic!("no valid node ids in direct node info");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ impl SignedNodeInfo {
|
|||
}
|
||||
pub fn node_info(&self) -> &NodeInfo {
|
||||
match self {
|
||||
SignedNodeInfo::Direct(d) => &d.node_info(),
|
||||
SignedNodeInfo::Relayed(r) => &r.node_info(),
|
||||
SignedNodeInfo::Direct(d) => d.node_info(),
|
||||
SignedNodeInfo::Relayed(r) => r.node_info(),
|
||||
}
|
||||
}
|
||||
pub fn relay_ids(&self) -> TypedKeyGroup {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl SignedRelayedNodeInfo {
|
|||
)?;
|
||||
let validated_node_ids =
|
||||
crypto.verify_signatures(node_ids, &node_info_bytes, &self.signatures)?;
|
||||
if validated_node_ids.len() == 0 {
|
||||
if validated_node_ids.is_empty() {
|
||||
apibail_generic!("no valid node ids in relayed node info");
|
||||
}
|
||||
Ok(validated_node_ids)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue