Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: Fix newly raised clippy warnings #3106

Merged
merged 6 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/identity/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl PublicKey {
}

let key_len = bitstr_head[1].checked_sub(1)? as usize;
let key_buf = asn1_buf.get(4 + oids_len + 3..4 + oids_len + 3 + key_len as usize)?;
let key_buf = asn1_buf.get(4 + oids_len + 3..4 + oids_len + 3 + key_len)?;
Some(key_buf)
}
}
Expand Down
2 changes: 1 addition & 1 deletion muxers/mplex/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl Decoder for Codec {
}

let buf = src.split_to(len);
let num = (header >> 3) as u64;
let num = header >> 3;
let out = match header & 7 {
0 => Frame::Open {
stream_id: RemoteStreamId::dialer(num),
Expand Down
4 changes: 2 additions & 2 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,9 +1265,9 @@ where
// Ask in random order
let mut iwant_ids_vec: Vec<_> = iwant_ids.into_iter().collect();
let mut rng = thread_rng();
iwant_ids_vec.partial_shuffle(&mut rng, iask as usize);
iwant_ids_vec.partial_shuffle(&mut rng, iask);

iwant_ids_vec.truncate(iask as usize);
iwant_ids_vec.truncate(iask);
*iasked += iask;

for message_id in &iwant_ids_vec {
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/peer_score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl PeerScore {

// P2: first message deliveries
let p2 = {
let v = topic_stats.first_message_deliveries as f64;
let v = topic_stats.first_message_deliveries;
if v < topic_params.first_message_deliveries_cap {
v
} else {
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/peer_score/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ fn test_score_ip_colocation() {
let n_shared = 3.0;
let ip_surplus = n_shared - ip_colocation_factor_threshold;
let penalty = ip_surplus * ip_surplus;
let expected = ip_colocation_factor_weight * penalty as f64;
let expected = ip_colocation_factor_weight * penalty;

assert_eq!(score_b, expected, "Peer B should have expected score");
assert_eq!(score_c, expected, "Peer C should have expected score");
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/subscription_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub trait TopicSubscriptionFilter {
}
}
self.filter_incoming_subscription_set(
filtered_subscriptions.into_iter().map(|(_, v)| v).collect(),
filtered_subscriptions.into_values().collect(),
currently_subscribed_topics,
)
}
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/kbucket/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ impl<T> From<Key<T>> for KeyBytes {

impl From<Multihash> for Key<Multihash> {
fn from(m: Multihash) -> Self {
let bytes = KeyBytes(Sha256::digest(&m.to_bytes()));
let bytes = KeyBytes(Sha256::digest(m.to_bytes()));
Key { preimage: m, bytes }
}
}

impl From<PeerId> for Key<PeerId> {
fn from(p: PeerId) -> Self {
let bytes = KeyBytes(Sha256::digest(&p.to_bytes()));
let bytes = KeyBytes(Sha256::digest(p.to_bytes()));
Key { preimage: p, bytes }
}
}
Expand Down
6 changes: 3 additions & 3 deletions protocols/kad/src/query/peers/closest/disjoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ mod tests {
impl std::fmt::Debug for Graph {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fmt.debug_list()
.entries(self.0.iter().map(|(id, _)| id))
.entries(self.0.keys())
.finish()
}
}
Expand Down Expand Up @@ -796,8 +796,8 @@ mod tests {
fn get_closest_peer(&self, target: &KeyBytes) -> PeerId {
*self
.0
.iter()
.map(|(peer_id, _)| (target.distance(&Key::from(*peer_id)), peer_id))
.keys()
.map(|peer_id| (target.distance(&Key::from(*peer_id)), peer_id))
.fold(None, |acc, (distance_b, peer_id_b)| match acc {
None => Some((distance_b, peer_id_b)),
Some((distance_a, peer_id_a)) => {
Expand Down
4 changes: 2 additions & 2 deletions protocols/relay/src/v2/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ impl NetworkBehaviour for Relay {
// Deny if it exceeds `max_reservations`.
|| self
.reservations
.iter()
.map(|(_, cs)| cs.len())
.values()
.map(|cs| cs.len())
.sum::<usize>()
>= self.config.max_reservations
// Deny if it exceeds the allowed rate of reservations.
Expand Down
2 changes: 1 addition & 1 deletion protocols/rendezvous/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ fn handle_outbound_event(
expiring_registrations.extend(registrations.iter().cloned().map(|registration| {
async move {
// if the timer errors we consider it expired
futures_timer::Delay::new(Duration::from_secs(registration.ttl as u64)).await;
futures_timer::Delay::new(Duration::from_secs(registration.ttl)).await;

(registration.record.peer_id(), registration.namespace)
}
Expand Down
2 changes: 1 addition & 1 deletion protocols/rendezvous/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl Registrations {
self.registrations
.insert(registration_id, registration.clone());

let next_expiry = futures_timer::Delay::new(Duration::from_secs(ttl as u64))
let next_expiry = futures_timer::Delay::new(Duration::from_secs(ttl))
.map(move |_| registration_id)
.boxed();

Expand Down