Skip to content

Commit

Permalink
cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
jxs committed Jan 9, 2024
1 parent feb3dba commit eaaee16
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ where
// Send to peers we know are subscribed to the topic.
let mut publish_failed = true;
for peer_id in recipient_peers.iter() {
if let Some(peer) = &mut self.connected_peers.get_mut(peer_id) {
if let Some(peer) = self.connected_peers.get_mut(peer_id) {
tracing::trace!(peer=%peer_id, "Sending message to peer");
match peer.sender.publish(
raw_message.clone(),
Expand Down Expand Up @@ -1340,32 +1340,30 @@ where
message=%id,
"IWANT: Peer has asked for message too many times; ignoring request"
);
} else {
if let Some(peer) = &mut self.connected_peers.get_mut(peer_id) {
tracing::debug!(peer=%peer_id, "IWANT: Sending cached messages to peer");
if peer
.sender
.forward(
msg,
self.config.forward_queue_duration(),
self.metrics.as_mut(),
)
.is_err()
{
// Downscore the peer
if let Some((peer_score, ..)) = &mut self.peer_score {
peer_score.failed_message_slow_peer(peer_id);
}
// Increment the failed message count
self.failed_messages
.entry(*peer_id)
.or_default()
.non_priority += 1;
} else if let Some(peer) = &mut self.connected_peers.get_mut(peer_id) {
tracing::debug!(peer=%peer_id, "IWANT: Sending cached messages to peer");
if peer
.sender
.forward(
msg,
self.config.forward_queue_duration(),
self.metrics.as_mut(),
)
.is_err()
{
// Downscore the peer
if let Some((peer_score, ..)) = &mut self.peer_score {
peer_score.failed_message_slow_peer(peer_id);
}
} else {
tracing::error!(peer = %peer_id,
"Could not IWANT, peer doesn't exist in connected peer list");
// Increment the failed message count
self.failed_messages
.entry(*peer_id)
.or_default()
.non_priority += 1;
}
} else {
tracing::error!(peer = %peer_id,
"Could not IWANT, peer doesn't exist in connected peer list");
}
}
}
Expand Down Expand Up @@ -2604,7 +2602,7 @@ where
self.config.do_px() && !no_px.contains(peer_id),
false,
);
if let Some(peer) = &mut self.connected_peers.get_mut(&peer_id) {
if let Some(peer) = self.connected_peers.get_mut(peer_id) {
peer.sender.prune(prune);
} else {
tracing::error!(peer = %peer_id,
Expand Down

0 comments on commit eaaee16

Please sign in to comment.