Skip to content

Commit f872040

Browse files
authored
[workspace] rustfmt (#3740)
1 parent 5a63d1f commit f872040

15 files changed

Lines changed: 135 additions & 167 deletions

File tree

consensus/src/marshal/coding/shards/engine.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,7 @@ where
517517
return;
518518
} => {
519519
// Track shard receipt per peer.
520-
self.metrics
521-
.shards_received
522-
.get_or_create_by(&peer)
523-
.inc();
520+
self.metrics.shards_received.get_or_create_by(&peer).inc();
524521

525522
let commitment = shard.commitment();
526523
if !self.should_handle_network_shard(commitment) {

consensus/src/simplex/actors/batcher/actor.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ where
400400
}
401401

402402
// Verify the certificate
403-
if !notarization.verify(self.context.as_mut(), &self.scheme, &self.strategy) {
403+
if !notarization.verify(self.context.as_mut(), &self.scheme, &self.strategy)
404+
{
404405
commonware_p2p::block!(self.blocker, sender, %view, "invalid notarization");
405406
continue;
406407
}
@@ -446,7 +447,8 @@ where
446447
}
447448

448449
// Verify the certificate
449-
if !finalization.verify(self.context.as_mut(), &self.scheme, &self.strategy) {
450+
if !finalization.verify(self.context.as_mut(), &self.scheme, &self.strategy)
451+
{
450452
commonware_p2p::block!(self.blocker, sender, %view, "invalid finalization");
451453
continue;
452454
}
@@ -503,7 +505,10 @@ where
503505
self.added.inc();
504506

505507
// Update per-peer latest vote metric (only if higher than current)
506-
let _ = self.latest_vote.get_or_create_by(&sender).try_set_max(view.get());
508+
let _ = self
509+
.latest_vote
510+
.get_or_create_by(&sender)
511+
.try_set_max(view.get());
507512

508513
// If the current leader explicitly nullifies the current view, signal
509514
// the voter so it can fast-path timeout without waiting for its local
@@ -592,9 +597,8 @@ where
592597
}
593598

594599
// Try to construct and forward certificates
595-
if let Some(notarization) = self
596-
.recover_latency
597-
.time_some(self.context.as_ref(), || {
600+
if let Some(notarization) =
601+
self.recover_latency.time_some(self.context.as_ref(), || {
598602
round.try_construct_notarization(&self.scheme, &self.strategy)
599603
})
600604
{
@@ -605,9 +609,8 @@ where
605609
.recovered(Certificate::Notarization(notarization))
606610
.await;
607611
}
608-
if let Some(nullification) = self
609-
.recover_latency
610-
.time_some(self.context.as_ref(), || {
612+
if let Some(nullification) =
613+
self.recover_latency.time_some(self.context.as_ref(), || {
611614
round.try_construct_nullification(&self.scheme, &self.strategy)
612615
})
613616
{
@@ -616,9 +619,8 @@ where
616619
.recovered(Certificate::Nullification(nullification))
617620
.await;
618621
}
619-
if let Some(finalization) = self
620-
.recover_latency
621-
.time_some(self.context.as_ref(), || {
622+
if let Some(finalization) =
623+
self.recover_latency.time_some(self.context.as_ref(), || {
622624
round.try_construct_finalization(&self.scheme, &self.strategy)
623625
})
624626
{

examples/reshare/src/dkg/actor.rs

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -498,42 +498,41 @@ where
498498
for (dealer, log) in storage.logs(epoch) {
499499
logs.record(dealer, log);
500500
}
501-
let (success, next_round, next_output, next_share) = if let Some(ps) =
502-
player_state.take()
503-
{
504-
match ps.finalize::<N3f1, Batch>(
505-
self.context.as_present_mut(),
506-
logs,
507-
&Sequential,
508-
) {
509-
Ok((new_output, new_share)) => (
510-
true,
511-
epoch_state.round + 1,
512-
Some(new_output),
513-
Some(new_share),
514-
),
515-
Err(_) => (
516-
false,
517-
epoch_state.round,
518-
epoch_state.output.clone(),
519-
epoch_state.share.clone(),
520-
),
521-
}
522-
} else {
523-
match observe::<_, _, N3f1, Batch>(
524-
self.context.as_present_mut(),
525-
logs,
526-
&Sequential,
527-
) {
528-
Ok(output) => (true, epoch_state.round + 1, Some(output), None),
529-
Err(_) => (
530-
false,
531-
epoch_state.round,
532-
epoch_state.output.clone(),
533-
epoch_state.share.clone(),
534-
),
535-
}
536-
};
501+
let (success, next_round, next_output, next_share) =
502+
if let Some(ps) = player_state.take() {
503+
match ps.finalize::<N3f1, Batch>(
504+
self.context.as_present_mut(),
505+
logs,
506+
&Sequential,
507+
) {
508+
Ok((new_output, new_share)) => (
509+
true,
510+
epoch_state.round + 1,
511+
Some(new_output),
512+
Some(new_share),
513+
),
514+
Err(_) => (
515+
false,
516+
epoch_state.round,
517+
epoch_state.output.clone(),
518+
epoch_state.share.clone(),
519+
),
520+
}
521+
} else {
522+
match observe::<_, _, N3f1, Batch>(
523+
self.context.as_present_mut(),
524+
logs,
525+
&Sequential,
526+
) {
527+
Ok(output) => (true, epoch_state.round + 1, Some(output), None),
528+
Err(_) => (
529+
false,
530+
epoch_state.round,
531+
epoch_state.output.clone(),
532+
epoch_state.share.clone(),
533+
),
534+
}
535+
};
537536
if success {
538537
info!(?epoch, "epoch succeeded");
539538
self.successful_epochs.inc();

examples/sync/src/bin/server.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -643,27 +643,20 @@ where
643643
}
644644
next_op_time = context.current() + config.op_interval;
645645
},
646-
client_result = listener.accept() => {
647-
match client_result {
648-
Ok((client_addr, sink, stream)) => {
649-
let state = state.clone();
650-
context.child("client").spawn(move |context| async move {
651-
if let Err(err) = handle_client::<DB, _, Mode>(
652-
context,
653-
state,
654-
sink,
655-
stream,
656-
client_addr,
657-
)
658-
.await
659-
{
660-
error!(client_addr = %client_addr, ?err, "error handling client");
661-
}
662-
});
663-
}
664-
Err(err) => {
665-
error!(?err, "failed to accept client");
666-
}
646+
client_result = listener.accept() => match client_result {
647+
Ok((client_addr, sink, stream)) => {
648+
let state = state.clone();
649+
context.child("client").spawn(move |context| async move {
650+
if let Err(err) =
651+
handle_client::<DB, _, Mode>(context, state, sink, stream, client_addr)
652+
.await
653+
{
654+
error!(client_addr = %client_addr, ?err, "error handling client");
655+
}
656+
});
657+
}
658+
Err(err) => {
659+
error!(?err, "failed to accept client");
667660
}
668661
},
669662
}

examples/sync/src/net/io.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,23 @@ async fn run_loop<E, Si, St, M>(
8989
let _ = sender.send(Err(Error::RequestChannelClosed));
9090
}
9191
return;
92-
} => {
93-
match M::decode(response_data.coalesce()) {
94-
Ok(message) => {
95-
let request_id = message.request_id();
96-
if let Some(sender) = pending_requests.remove(&request_id) {
97-
let _ = sender.send(Ok(message));
98-
}
92+
} => match M::decode(response_data.coalesce()) {
93+
Ok(message) => {
94+
let request_id = message.request_id();
95+
if let Some(sender) = pending_requests.remove(&request_id) {
96+
let _ = sender.send(Ok(message));
9997
}
100-
Err(_) => {
101-
recv_handle.abort();
102-
warn!(
103-
pending_count = pending_requests.len(),
104-
"failed to decode response; terminating I/O task"
105-
);
106-
for (_, sender) in pending_requests.drain() {
107-
let _ = sender.send(Err(Error::InvalidResponse));
108-
}
109-
return;
98+
}
99+
Err(_) => {
100+
recv_handle.abort();
101+
warn!(
102+
pending_count = pending_requests.len(),
103+
"failed to decode response; terminating I/O task"
104+
);
105+
for (_, sender) in pending_requests.drain() {
106+
let _ = sender.send(Err(Error::InvalidResponse));
110107
}
108+
return;
111109
}
112110
},
113111
}

formatting/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ commonware_macros::stability_scope!(BETA {
2727
pub fn from_hex(s: &str) -> Option<Vec<u8>> {
2828
// "0x" prefix stripping is handled by `const-hex::decode`.
2929
let s = s.replace(['\t', '\n', '\r', ' '], "");
30-
let stripped = s
31-
.strip_prefix("0X")
32-
.unwrap_or(&s);
30+
let stripped = s.strip_prefix("0X").unwrap_or(&s);
3331
const_hex::decode(stripped).ok()
3432
}
3533

p2p/src/authenticated/discovery/actors/listener.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,7 @@ impl<E: Spawner + BufferPooler + Clock + Network + CryptoRngCore + Metrics, C: S
225225
let supervisor = supervisor.clone();
226226
move |context| async move {
227227
Self::handshake(
228-
context,
229-
address,
230-
stream_cfg,
231-
sink,
232-
stream,
233-
tracker,
234-
supervisor,
228+
context, address, stream_cfg, sink, stream, tracker, supervisor,
235229
)
236230
.await;
237231

p2p/src/authenticated/discovery/actors/peer/actor.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,7 @@ impl<E: Spawner + BufferPooler + Clock + CryptoRngCore + Metrics, C: PublicKey>
220220
msg = recv_prioritized(control, high, low) => {
221221
let (metric, payload) = match msg {
222222
Prioritized::Closed => return Err(Error::PeerDisconnected),
223-
Prioritized::Control(msg) => {
224-
Self::prepare_control(&peer, msg, &pool)?
225-
}
223+
Prioritized::Control(msg) => Self::prepare_control(&peer, msg, &pool)?,
226224
Prioritized::Data(encoded) => {
227225
Self::prepare_data(&peer, encoded, &rate_limits)
228226
}

p2p/src/authenticated/lookup/actors/listener.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,7 @@ impl<E: Spawner + BufferPooler + Clock + Network + CryptoRngCore + Metrics, C: S
253253
let supervisor = supervisor.clone();
254254
move |context| async move {
255255
Self::handshake(
256-
context,
257-
address,
258-
stream_cfg,
259-
sink,
260-
stream,
261-
tracker,
262-
supervisor,
256+
context, address, stream_cfg, sink, stream, tracker, supervisor,
263257
)
264258
.await;
265259

p2p/src/authenticated/lookup/actors/peer/actor.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,7 @@ impl<E: Spawner + BufferPooler + Clock + CryptoRngCore + Metrics, C: PublicKey>
198198
match msg {
199199
Prioritized::Closed => return Err(Error::PeerDisconnected),
200200
Prioritized::Control(msg) => match msg {
201-
Message::Kill => {
202-
return Err(Error::PeerKilled(peer.to_string()))
203-
}
201+
Message::Kill => return Err(Error::PeerKilled(peer.to_string())),
204202
},
205203
Prioritized::Data(encoded) => {
206204
let (metric, payload) =

0 commit comments

Comments
 (0)