Skip to content

Commit

Permalink
Simplfy nested if let to single if let
Browse files Browse the repository at this point in the history
  • Loading branch information
birchmd committed Sep 15, 2020
1 parent 7ee90fb commit ddacef7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions chain/network/src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use crate::types::{
NetworkClientMessages, NetworkClientResponses, NetworkRequests, NetworkViewClientMessages,
NetworkViewClientResponses, PeerChainInfo, PeerInfo, PeerManagerRequest, PeerMessage,
PeerRequest, PeerResponse, PeerStatsResult, PeerStatus, PeerType, PeersRequest, PeersResponse,
QueryPeerStats, ReasonForBan, RoutedMessageBody, RoutedMessageFrom, SendMessage, Unregister,
UPDATE_INTERVAL_LAST_TIME_RECEIVED_MESSAGE,
QueryPeerStats, ReasonForBan, RoutedMessage, RoutedMessageBody, RoutedMessageFrom, SendMessage,
Unregister, UPDATE_INTERVAL_LAST_TIME_RECEIVED_MESSAGE,
};
use crate::PeerManagerActor;
use crate::{metrics, NetworkResponses};
Expand Down Expand Up @@ -659,10 +659,11 @@ impl StreamHandler<Result<Vec<u8>, ReasonForBan>> for Peer {
return;
}
};
if let PeerMessage::Routed(rm) = &peer_msg {
if let RoutedMessageBody::ForwardTx(_) = rm.body {
self.txns_since_last_block.fetch_add(1, Ordering::AcqRel);
}
if let PeerMessage::Routed(RoutedMessage {
body: RoutedMessageBody::ForwardTx(_), ..
}) = &peer_msg
{
self.txns_since_last_block.fetch_add(1, Ordering::AcqRel);
} else if let PeerMessage::Block(_) = &peer_msg {
self.txns_since_last_block.store(0, Ordering::Release);
}
Expand Down

0 comments on commit ddacef7

Please sign in to comment.