mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-27 17:51:20 +00:00
*: Fix various clippy warnings (#2900)
This commit is contained in:
parent
2c739e9bdb
commit
c81b06a9b2
@ -649,7 +649,7 @@ where
|
||||
set.iter()
|
||||
.filter(|p| {
|
||||
self.explicit_peers.contains(*p)
|
||||
|| !self.score_below_threshold(*p, |ts| ts.publish_threshold).0
|
||||
|| !self.score_below_threshold(p, |ts| ts.publish_threshold).0
|
||||
})
|
||||
.cloned(),
|
||||
);
|
||||
@ -946,14 +946,11 @@ where
|
||||
);
|
||||
|
||||
// remove explicit peers, peers with negative scores, and backoffed peers
|
||||
peers = peers
|
||||
.into_iter()
|
||||
.filter(|p| {
|
||||
!self.explicit_peers.contains(p)
|
||||
&& !self.score_below_threshold(p, |_| 0.0).0
|
||||
&& !self.backoffs.is_backoff_with_slack(topic_hash, p)
|
||||
})
|
||||
.collect();
|
||||
peers.retain(|p| {
|
||||
!self.explicit_peers.contains(p)
|
||||
&& !self.score_below_threshold(p, |_| 0.0).0
|
||||
&& !self.backoffs.is_backoff_with_slack(topic_hash, p)
|
||||
});
|
||||
|
||||
// Add up to mesh_n of them them to the mesh
|
||||
// NOTE: These aren't randomly added, currently FIFO
|
||||
@ -1625,7 +1622,7 @@ where
|
||||
//
|
||||
//TODO: Once signed records are spec'd: Can we use peerInfo without any IDs if they have a
|
||||
// signed peer record?
|
||||
px = px.into_iter().filter(|p| p.peer_id.is_some()).collect();
|
||||
px.retain(|p| p.peer_id.is_some());
|
||||
if px.len() > n {
|
||||
// only use at most prune_peers many random peers
|
||||
let mut rng = thread_rng();
|
||||
@ -3204,7 +3201,7 @@ where
|
||||
debug!("Peer disconnected: {}", peer_id);
|
||||
{
|
||||
let topics = match self.peer_topics.get(peer_id) {
|
||||
Some(topics) => (topics),
|
||||
Some(topics) => topics,
|
||||
None => {
|
||||
debug_assert!(
|
||||
self.blacklisted_peers.contains(peer_id),
|
||||
|
@ -658,14 +658,7 @@ where
|
||||
let pos = self
|
||||
.inbound_substreams
|
||||
.iter()
|
||||
.position(|state| match state {
|
||||
InboundSubstreamState::WaitingUser(ref conn_id, _)
|
||||
if conn_id == &request_id.connec_unique_id =>
|
||||
{
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
.position(|state| matches!(state, InboundSubstreamState::WaitingUser(ref conn_id, _) if conn_id == &request_id.connec_unique_id));
|
||||
|
||||
if let Some(pos) = pos {
|
||||
let (conn_id, substream) = match self.inbound_substreams.remove(pos) {
|
||||
@ -737,14 +730,7 @@ where
|
||||
let pos = self
|
||||
.inbound_substreams
|
||||
.iter()
|
||||
.position(|state| match state {
|
||||
InboundSubstreamState::WaitingUser(ref conn_id, _)
|
||||
if conn_id == &request_id.connec_unique_id =>
|
||||
{
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
.position(|state| matches!(state, InboundSubstreamState::WaitingUser(ref conn_id, _) if conn_id == &request_id.connec_unique_id));
|
||||
|
||||
if let Some(pos) = pos {
|
||||
let (conn_id, substream) = match self.inbound_substreams.remove(pos) {
|
||||
|
@ -85,7 +85,7 @@ where
|
||||
socket.bind(&SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 5353).into())?;
|
||||
socket.set_multicast_loop_v4(true)?;
|
||||
socket.set_multicast_ttl_v4(255)?;
|
||||
socket.join_multicast_v4(&*crate::IPV4_MDNS_MULTICAST_ADDRESS, &addr)?;
|
||||
socket.join_multicast_v4(&crate::IPV4_MDNS_MULTICAST_ADDRESS, &addr)?;
|
||||
U::from_std(UdpSocket::from(socket))?
|
||||
}
|
||||
IpAddr::V6(_) => {
|
||||
@ -96,7 +96,7 @@ where
|
||||
socket.bind(&SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), 5353).into())?;
|
||||
socket.set_multicast_loop_v6(true)?;
|
||||
// TODO: find interface matching addr.
|
||||
socket.join_multicast_v6(&*crate::IPV6_MDNS_MULTICAST_ADDRESS, 0)?;
|
||||
socket.join_multicast_v6(&crate::IPV6_MDNS_MULTICAST_ADDRESS, 0)?;
|
||||
U::from_std(UdpSocket::from(socket))?
|
||||
}
|
||||
};
|
||||
|
@ -246,7 +246,7 @@ fn query_response_packet(id: u16, peer_id: &[u8], records: &[Vec<u8>], ttl: u32)
|
||||
fn duration_to_secs(duration: Duration) -> u32 {
|
||||
let secs = duration
|
||||
.as_secs()
|
||||
.saturating_add(if duration.subsec_nanos() > 0 { 1 } else { 0 });
|
||||
.saturating_add(u64::from(duration.subsec_nanos() > 0));
|
||||
cmp::min(secs, From::from(u32::max_value())) as u32
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user