Rust 1.84 lints (#6781)

* Fix few lints

* Fix remaining lints

* Use fully qualified syntax
This commit is contained in:
Pawan Dhananjay
2025-01-10 06:43:29 +05:30
committed by GitHub
parent 87b72dec21
commit 1f6850fae2
61 changed files with 110 additions and 138 deletions

View File

@@ -166,7 +166,7 @@ impl Config {
tcp_port,
});
self.discv5_config.listen_config = discv5::ListenConfig::from_ip(addr.into(), disc_port);
self.discv5_config.table_filter = |enr| enr.ip4().as_ref().map_or(false, is_global_ipv4)
self.discv5_config.table_filter = |enr| enr.ip4().as_ref().is_some_and(is_global_ipv4)
}
/// Sets the listening address to use an ipv6 address. The discv5 ip_mode and table filter is
@@ -187,7 +187,7 @@ impl Config {
});
self.discv5_config.listen_config = discv5::ListenConfig::from_ip(addr.into(), disc_port);
self.discv5_config.table_filter = |enr| enr.ip6().as_ref().map_or(false, is_global_ipv6)
self.discv5_config.table_filter = |enr| enr.ip6().as_ref().is_some_and(is_global_ipv6)
}
/// Sets the listening address to use both an ipv4 and ipv6 address. The discv5 ip_mode and
@@ -317,7 +317,7 @@ impl Default for Config {
.filter_rate_limiter(filter_rate_limiter)
.filter_max_bans_per_ip(Some(5))
.filter_max_nodes_per_ip(Some(10))
.table_filter(|enr| enr.ip4().map_or(false, |ip| is_global_ipv4(&ip))) // Filter non-global IPs
.table_filter(|enr| enr.ip4().is_some_and(|ip| is_global_ipv4(&ip))) // Filter non-global IPs
.ban_duration(Some(Duration::from_secs(3600)))
.ping_interval(Duration::from_secs(300))
.build();

View File

@@ -35,7 +35,7 @@ where
.unwrap_or(false),
Subnet::SyncCommittee(s) => sync_committee_bitfield
.as_ref()
.map_or(false, |b| b.get(*s.deref() as usize).unwrap_or(false)),
.is_ok_and(|b| b.get(*s.deref() as usize).unwrap_or(false)),
Subnet::DataColumn(s) => {
if let Ok(custody_subnet_count) = enr.custody_subnet_count::<E>(&spec) {
DataColumnSubnetId::compute_custody_subnets::<E>(
@@ -43,7 +43,7 @@ where
custody_subnet_count,
&spec,
)
.map_or(false, |mut subnets| subnets.contains(s))
.is_ok_and(|mut subnets| subnets.contains(s))
} else {
false
}

View File

@@ -1305,7 +1305,7 @@ impl BannedPeersCount {
pub fn ip_is_banned(&self, ip: &IpAddr) -> bool {
self.banned_peers_per_ip
.get(ip)
.map_or(false, |count| *count > BANNED_PEERS_PER_IP_THRESHOLD)
.is_some_and(|count| *count > BANNED_PEERS_PER_IP_THRESHOLD)
}
}

View File

@@ -99,7 +99,7 @@ impl<E: EthSpec> PeerInfo<E> {
Subnet::SyncCommittee(id) => {
return meta_data
.syncnets()
.map_or(false, |s| s.get(**id as usize).unwrap_or(false))
.is_ok_and(|s| s.get(**id as usize).unwrap_or(false))
}
Subnet::DataColumn(column) => return self.custody_subnets.contains(column),
}
@@ -264,7 +264,7 @@ impl<E: EthSpec> PeerInfo<E> {
/// Reports if this peer has some future validator duty in which case it is valuable to keep it.
pub fn has_future_duty(&self) -> bool {
self.min_ttl.map_or(false, |i| i >= Instant::now())
self.min_ttl.is_some_and(|i| i >= Instant::now())
}
/// Returns score of the peer.