Skip to content

Commit

Permalink
Appease the all-wise all-knowing clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
AgeManning committed Aug 8, 2023
1 parent 4c9159c commit 3492646
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
5 changes: 2 additions & 3 deletions beacon_node/lighthouse_network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ impl Config {
/// Sets the listening address to use both an ipv4 and ipv6 address. The discv5 ip_mode and
/// table filter is adjusted accordingly to ensure addresses that are present in the enr are
/// globally reachable.
/// TODO: add Quic support IPV6 port when https://github.com/libp2p/rust-libp2p/issues/4165
/// gets addressed.
#[allow(clippy::too_many_arguments)]
pub fn set_ipv4_ipv6_listening_addresses(
&mut self,
v4_addr: Ipv4Addr,
Expand Down Expand Up @@ -592,4 +591,4 @@ pub const fn is_global_ipv6(addr: &Ipv6Addr) -> bool {
|| is_documentation(addr)
|| is_unique_local(addr)
|| is_unicast_link_local(addr))
}
}
6 changes: 3 additions & 3 deletions beacon_node/lighthouse_network/src/discovery/enr_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use libp2p::core::multiaddr::Protocol;
use libp2p::identity::{ed25519, secp256k1, KeyType, Keypair, PublicKey};
use tiny_keccak::{Hasher, Keccak};

const QUIC_ENR_KEY: &'static str = "quic";
const QUIC6_ENR_KEY: &'static str = "quic6";
const QUIC_ENR_KEY: &str = "quic";
const QUIC6_ENR_KEY: &str = "quic6";

/// Extend ENR for libp2p types.
pub trait EnrExt {
Expand Down Expand Up @@ -397,4 +397,4 @@ mod tests {

assert_eq!(enr.node_id(), node_id);
}
}
}
4 changes: 2 additions & 2 deletions beacon_node/lighthouse_network/src/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,6 @@ mod tests {
assert_eq!(results.len(), 2);

// when a peer belongs to multiple subnet ids, we use the highest ttl.
assert_eq!(results.get(&enr1.peer_id()).unwrap(), &instant1);
assert_eq!(results.get(&enr1).unwrap(), &instant1);
}
}
}
6 changes: 2 additions & 4 deletions beacon_node/lighthouse_network/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,8 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {

for listen_multiaddr in config.listen_addrs().listen_addresses() {
// If QUIC is disabled, ignore listening on QUIC ports
if config.disable_quic_support {
if listen_multiaddr.iter().any(|v| v == MProtocol::QuicV1) {
if config.disable_quic_support && listen_multiaddr.iter().any(|v| v == MProtocol::QuicV1) {
continue;
}
}

match self.swarm.listen_on(listen_multiaddr.clone()) {
Expand Down Expand Up @@ -1601,4 +1599,4 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
pub async fn next_event(&mut self) -> NetworkEvent<AppReqId, TSpec> {
futures::future::poll_fn(|cx| self.poll_network(cx)).await
}
}
}
14 changes: 5 additions & 9 deletions beacon_node/network/src/nat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,13 @@ pub fn construct_upnp_mappings<T: EthSpec>(
let mut udp_sockets = Vec::new();

// Set the discovery UDP port mapping
if !config.disable_discovery {
if set_udp_mapping(config.disc_port).is_ok() {
udp_sockets.push(config.disc_port);
}
if !config.disable_discovery && set_udp_mapping(config.disc_port).is_ok() {
udp_sockets.push(config.disc_port);
}

// Set the quic UDP port mapping
if !config.disable_quic_support {
if set_udp_mapping(config.quic_port).is_ok() {
udp_sockets.push(config.quic_port)
}
if !config.disable_quic_support && set_udp_mapping(config.quic_port).is_ok() {
udp_sockets.push(config.quic_port)
}

// report any updates to the network service.
Expand Down Expand Up @@ -203,4 +199,4 @@ pub fn remove_mappings(tcp_port: Option<u16>, udp_ports: &[u16], log: &slog::Log
Err(e) => debug!(log, "UPnP failed to remove mappings"; "error" => %e),
}
}
}
}

0 comments on commit 3492646

Please sign in to comment.