Fix lots of small nits in sc-network (#6028)

* Fix lots of small nits in sc-network

* Update client/network/src/protocol/sync/blocks.rs

Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com>

* Fix warning

* Yes. The line width.

Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com>
This commit is contained in:
Pierre Krieger
2020-05-15 13:58:52 +02:00
committed by GitHub
parent 1dbd761192
commit 6ecdf20a1f
14 changed files with 111 additions and 112 deletions
@@ -507,7 +507,7 @@ impl GenericProto {
///
/// Can be called multiple times with the same `PeerId`s.
pub fn add_discovered_nodes(&mut self, peer_ids: impl Iterator<Item = PeerId>) {
self.peerset.discovered(peer_ids.into_iter().map(|peer_id| {
self.peerset.discovered(peer_ids.map(|peer_id| {
debug!(target: "sub-libp2p", "PSM <= Discovered({:?})", peer_id);
peer_id
}));
@@ -616,8 +616,8 @@ impl GenericProto {
debug!(target: "sub-libp2p", "PSM => Connect({:?}): Will start to connect at \
until {:?}", occ_entry.key(), until);
*occ_entry.into_mut() = PeerState::PendingRequest {
timer: futures_timer::Delay::new(until.clone() - now),
timer_deadline: until.clone(),
timer: futures_timer::Delay::new(*until - now),
timer_deadline: *until,
};
},
@@ -639,8 +639,8 @@ impl GenericProto {
occ_entry.key(), banned);
*occ_entry.into_mut() = PeerState::DisabledPendingEnable {
open,
timer: futures_timer::Delay::new(banned.clone() - now),
timer_deadline: banned.clone(),
timer: futures_timer::Delay::new(*banned - now),
timer_deadline: *banned,
};
},
@@ -879,7 +879,7 @@ impl NetworkBehaviour for GenericProto {
// this peer", and not "banned" in the sense that we would refuse the peer altogether.
(st @ &mut PeerState::Poisoned, endpoint @ ConnectedPoint::Listener { .. }) |
(st @ &mut PeerState::Banned { .. }, endpoint @ ConnectedPoint::Listener { .. }) => {
let incoming_id = self.next_incoming_index.clone();
let incoming_id = self.next_incoming_index;
self.next_incoming_index.0 = match self.next_incoming_index.0.checked_add(1) {
Some(v) => v,
None => {
@@ -1200,7 +1200,7 @@ impl NetworkBehaviour for GenericProto {
debug!(target: "sub-libp2p", "External API <= Closed({:?})", source);
let event = GenericProtoOut::CustomProtocolClosed {
reason,
peer_id: source.clone(),
peer_id: source,
};
self.events.push(NetworkBehaviourAction::GenerateEvent(event));
} else {
@@ -1384,7 +1384,7 @@ impl NetworkBehaviour for GenericProto {
*peer_state = PeerState::Enabled { open };
}
st @ _ => *peer_state = st,
st => *peer_state = st,
}
}
@@ -483,35 +483,35 @@ impl ProtocolsHandler for NotifsHandler {
) -> Poll<
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>
> {
while let Poll::Ready(ev) = self.legacy.poll(cx) {
match ev {
if let Poll::Ready(ev) = self.legacy.poll(cx) {
return match ev {
ProtocolsHandlerEvent::OutboundSubstreamRequest { protocol, info: () } =>
return Poll::Ready(ProtocolsHandlerEvent::OutboundSubstreamRequest {
Poll::Ready(ProtocolsHandlerEvent::OutboundSubstreamRequest {
protocol: protocol.map_upgrade(EitherUpgrade::B),
info: None,
}),
ProtocolsHandlerEvent::Custom(LegacyProtoHandlerOut::CustomProtocolOpen { endpoint, .. }) =>
return Poll::Ready(ProtocolsHandlerEvent::Custom(
Poll::Ready(ProtocolsHandlerEvent::Custom(
NotifsHandlerOut::Open { endpoint }
)),
ProtocolsHandlerEvent::Custom(LegacyProtoHandlerOut::CustomProtocolClosed { endpoint, reason }) =>
return Poll::Ready(ProtocolsHandlerEvent::Custom(
Poll::Ready(ProtocolsHandlerEvent::Custom(
NotifsHandlerOut::Closed { endpoint, reason }
)),
ProtocolsHandlerEvent::Custom(LegacyProtoHandlerOut::CustomMessage { message }) =>
return Poll::Ready(ProtocolsHandlerEvent::Custom(
Poll::Ready(ProtocolsHandlerEvent::Custom(
NotifsHandlerOut::CustomMessage { message }
)),
ProtocolsHandlerEvent::Custom(LegacyProtoHandlerOut::Clogged { messages }) =>
return Poll::Ready(ProtocolsHandlerEvent::Custom(
Poll::Ready(ProtocolsHandlerEvent::Custom(
NotifsHandlerOut::Clogged { messages }
)),
ProtocolsHandlerEvent::Custom(LegacyProtoHandlerOut::ProtocolError { is_severe, error }) =>
return Poll::Ready(ProtocolsHandlerEvent::Custom(
Poll::Ready(ProtocolsHandlerEvent::Custom(
NotifsHandlerOut::ProtocolError { is_severe, error }
)),
ProtocolsHandlerEvent::Close(err) =>
return Poll::Ready(ProtocolsHandlerEvent::Close(EitherError::B(err))),
Poll::Ready(ProtocolsHandlerEvent::Close(EitherError::B(err))),
}
}
@@ -390,8 +390,8 @@ pub enum NotificationsOutError {
/// Remote doesn't process our messages quickly enough.
///
/// > **Note**: This is not necessarily the remote's fault, and could also be caused by the
/// > local node sending data too quickly. Properly doing back-pressure, however,
/// > would require a deep refactoring effort in Substrate as a whole.
/// > local node sending data too quickly. Properly doing back-pressure, however,
/// > would require a deep refactoring effort in Substrate as a whole.
Clogged,
}