Skip to content

Commit

Permalink
*: Format with rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Aug 20, 2021
1 parent a78de13 commit d4960b7
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 21 deletions.
2 changes: 1 addition & 1 deletion core/src/connection/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl<THandler: IntoConnectionHandler, TTransErr> Pool<THandler, TTransErr> {
/// > performing such an orderly close.
pub fn disconnect(&mut self, peer: &PeerId) {
if let Some(conns) = self.established.get(peer) {
for (&id, endpoint) in conns.iter() {
for (&id, _endpoint) in conns.iter() {
if let Some(manager::Entry::Established(e)) = self.manager.entry(id) {
e.start_close(None);
}
Expand Down
2 changes: 1 addition & 1 deletion core/tests/connection_limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn max_outgoing() {
.dial(Multiaddr::empty(), Vec::new(), TestHandler())
.expect_err("Unexpected dialing success.")
{
DialError::ConnectionLimit{limit, handler: _} => {
DialError::ConnectionLimit { limit, handler: _ } => {
assert_eq!(limit.current, outgoing_limit);
assert_eq!(limit.limit, outgoing_limit);
}
Expand Down
5 changes: 4 additions & 1 deletion core/tests/network_dial_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ fn multiple_addresses_err() {
assert_eq!(Into::<u32>::into(&attempts_remaining), 0);
return Poll::Ready(Ok(()));
} else {
assert_eq!(Into::<u32>::into(&attempts_remaining), addresses.len() as u32);
assert_eq!(
Into::<u32>::into(&attempts_remaining),
addresses.len() as u32
);
}
}
Poll::Ready(_) => unreachable!(),
Expand Down
6 changes: 5 additions & 1 deletion protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3176,7 +3176,11 @@ where
_: &mut impl PollParameters,
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
if let Some(event) = self.events.pop_front() {
let event: NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler, Arc<GossipsubHandlerIn>> = event;
let event: NetworkBehaviourAction<
Self::OutEvent,
Self::ProtocolsHandler,
Arc<GossipsubHandlerIn>,
> = event;
return Poll::Ready(event.map_in(|e: Arc<GossipsubHandlerIn>| {
// clone send event reference if others references are present
Arc::try_unwrap(e).unwrap_or_else(|e| (*e).clone())
Expand Down
7 changes: 1 addition & 6 deletions protocols/mdns/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,7 @@ impl NetworkBehaviour for Mdns {
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters,
) -> Poll<
NetworkBehaviourAction<
Self::OutEvent,
DummyProtocolsHandler,
>,
> {
) -> Poll<NetworkBehaviourAction<Self::OutEvent, DummyProtocolsHandler>> {
while let Poll::Ready(event) = Pin::new(&mut self.if_watch).poll(cx) {
let socket = self.recv_socket.get_ref();
match event {
Expand Down
3 changes: 2 additions & 1 deletion protocols/relay/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,8 @@ impl CombinedBehaviour {
&mut self,
_: &mut Context,
_: &mut impl PollParameters,
) -> Poll<NetworkBehaviourAction<CombinedEvent, <Self as NetworkBehaviour>::ProtocolsHandler>> {
) -> Poll<NetworkBehaviourAction<CombinedEvent, <Self as NetworkBehaviour>::ProtocolsHandler>>
{
if !self.events.is_empty() {
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(self.events.remove(0)));
}
Expand Down
15 changes: 11 additions & 4 deletions protocols/request-response/src/throttled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ where
end: &ConnectedPoint,
handler: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
) {
self.behaviour.inject_connection_closed(peer, id, end, handler);
self.behaviour
.inject_connection_closed(peer, id, end, handler);
if let Some(info) = self.peer_info.get_mut(peer) {
if let Some(grant) = &mut info.recv_budget.grant {
log::debug! { "{:08x}: resending credit grant {} to {} after connection closed",
Expand Down Expand Up @@ -748,9 +749,15 @@ where
NetworkBehaviourAction::DialAddress { address, handler } => {
NetworkBehaviourAction::DialAddress { address, handler }
}
NetworkBehaviourAction::DialPeer { peer_id, condition, handler } => {
NetworkBehaviourAction::DialPeer { peer_id, condition, handler }
}
NetworkBehaviourAction::DialPeer {
peer_id,
condition,
handler,
} => NetworkBehaviourAction::DialPeer {
peer_id,
condition,
handler,
},
NetworkBehaviourAction::NotifyHandler {
peer_id,
handler,
Expand Down
14 changes: 12 additions & 2 deletions swarm-derive/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ fn custom_polling() {
&mut self,
_: &mut std::task::Context,
_: &mut impl libp2p::swarm::PollParameters,
) -> std::task::Poll<libp2p::swarm::NetworkBehaviourAction<<Self as NetworkBehaviour>::OutEvent, <Self as NetworkBehaviour>::ProtocolsHandler>> {
) -> std::task::Poll<
libp2p::swarm::NetworkBehaviourAction<
<Self as NetworkBehaviour>::OutEvent,
<Self as NetworkBehaviour>::ProtocolsHandler,
>,
> {
std::task::Poll::Pending
}
}
Expand Down Expand Up @@ -211,7 +216,12 @@ fn custom_event_and_polling() {
&mut self,
_: &mut std::task::Context,
_: &mut impl libp2p::swarm::PollParameters,
) -> std::task::Poll<libp2p::swarm::NetworkBehaviourAction<<Self as NetworkBehaviour>::OutEvent, <Self as NetworkBehaviour>::ProtocolsHandler>> {
) -> std::task::Poll<
libp2p::swarm::NetworkBehaviourAction<
<Self as NetworkBehaviour>::OutEvent,
<Self as NetworkBehaviour>::ProtocolsHandler,
>,
> {
std::task::Poll::Pending
}
}
Expand Down
8 changes: 4 additions & 4 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,10 +1358,10 @@ mod tests {
}
[swarm1, swarm2]
.iter()
.all(|s| s.behaviour.inject_connection_closed.len() == num_connections) &&
[swarm1, swarm2]
.iter()
.all(|s| s.behaviour.inject_disconnected.len() == 1)
.all(|s| s.behaviour.inject_connection_closed.len() == num_connections)
&& [swarm1, swarm2]
.iter()
.all(|s| s.behaviour.inject_disconnected.len() == 1)
}

/// Establishes multiple connections between two peers,
Expand Down

0 comments on commit d4960b7

Please sign in to comment.