Skip to content

Commit e7fd5af

Browse files
authored
[workspace] rustfmt (#3457)
1 parent b65ed8f commit e7fd5af

13 files changed

Lines changed: 150 additions & 106 deletions

File tree

coding/src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,15 @@ commonware_macros::stability_scope!(ALPHA {
452452
config,
453453
commitment,
454454
checking_data.clone(),
455-
shards.map(|shard| {
456-
if shard.checking_data != checking_data {
457-
return Err(PhasedAsSchemeError::InconsistentCheckingData);
458-
}
459-
Ok(&shard.checked_shard)
460-
})
461-
.collect::<Result<Vec<_>, _>>()?
462-
.into_iter(),
455+
shards
456+
.map(|shard| {
457+
if shard.checking_data != checking_data {
458+
return Err(PhasedAsSchemeError::InconsistentCheckingData);
459+
}
460+
Ok(&shard.checked_shard)
461+
})
462+
.collect::<Result<Vec<_>, _>>()?
463+
.into_iter(),
463464
strategy,
464465
)
465466
.map_err(PhasedAsSchemeError::Scheme)

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,11 @@ where
429429
subscribers.retain(|tx| !tx.is_closed());
430430
!subscribers.is_empty()
431431
});
432-
self.assigned_shard_verified_subscriptions.retain(|_, subscribers| {
433-
subscribers.retain(|tx| !tx.is_closed());
434-
!subscribers.is_empty()
435-
});
432+
self.assigned_shard_verified_subscriptions
433+
.retain(|_, subscribers| {
434+
subscribers.retain(|tx| !tx.is_closed());
435+
!subscribers.is_empty()
436+
});
436437
},
437438
on_stopped => {
438439
debug!("received shutdown signal, stopping shard engine");

consensus/src/marshal/standard/inline.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,17 @@ where
9898
);
9999
None
100100
},
101-
result = block_rx => result.map_or_else(|_| {
101+
result = block_rx => {
102+
if result.is_err() {
102103
debug!(
103104
stage,
104105
?digest,
105106
reason = "failed to fetch block",
106107
"skipping block wait"
107108
);
108-
None
109-
}, Some),
109+
}
110+
result.ok()
111+
},
110112
}
111113
}
112114

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ where
353353
// Forward the proposal, if enabled and we have something to forward
354354
if let Some((proposal, round)) = forwardable_proposal
355355
.filter(|_| self.forwarding.is_enabled())
356-
.and_then(|proposal| work.get(&proposal.view()).map(|round| (proposal, round)))
356+
.and_then(|proposal| {
357+
work.get(&proposal.view()).map(|round| (proposal, round))
358+
})
357359
{
358360
let participants = self.forward_targets(round, &proposal, leader);
359361
self.forward_proposal(proposal, participants).await;

consensus/src/simplex/actors/voter/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6238,7 +6238,7 @@ mod tests {
62386238
}
62396239
}
62406240
_ => {}
6241-
}
6241+
},
62426242
}
62436243
};
62446244
assert!(!reached_view2, "view advanced before finalize for view 1");
@@ -6261,7 +6261,7 @@ mod tests {
62616261
}
62626262
}
62636263
_ => {}
6264-
}
6264+
},
62656265
}
62666266
};
62676267
assert!(reached_view2, "expected progress to view 2 from view 1");

examples/reshare/src/dkg/actor.rs

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -522,41 +522,35 @@ where
522522
for (dealer, log) in storage.logs(epoch) {
523523
logs.record(dealer, log);
524524
}
525-
let (success, next_round, next_output, next_share) =
526-
if let Some(ps) = player_state.take() {
527-
match ps.finalize::<N3f1, Batch>(
528-
&mut self.context,
529-
logs,
530-
&Sequential,
531-
) {
532-
Ok((new_output, new_share)) => (
533-
true,
534-
epoch_state.round + 1,
535-
Some(new_output),
536-
Some(new_share),
537-
),
538-
Err(_) => (
539-
false,
540-
epoch_state.round,
541-
epoch_state.output.clone(),
542-
epoch_state.share.clone(),
543-
),
544-
}
545-
} else {
546-
match observe::<_, _, N3f1, Batch>(
547-
&mut self.context,
548-
logs,
549-
&Sequential,
550-
) {
551-
Ok(output) => (true, epoch_state.round + 1, Some(output), None),
552-
Err(_) => (
553-
false,
554-
epoch_state.round,
555-
epoch_state.output.clone(),
556-
epoch_state.share.clone(),
557-
),
558-
}
559-
};
525+
let (success, next_round, next_output, next_share) = if let Some(ps) =
526+
player_state.take()
527+
{
528+
match ps.finalize::<N3f1, Batch>(&mut self.context, logs, &Sequential) {
529+
Ok((new_output, new_share)) => (
530+
true,
531+
epoch_state.round + 1,
532+
Some(new_output),
533+
Some(new_share),
534+
),
535+
Err(_) => (
536+
false,
537+
epoch_state.round,
538+
epoch_state.output.clone(),
539+
epoch_state.share.clone(),
540+
),
541+
}
542+
} else {
543+
match observe::<_, _, N3f1, Batch>(&mut self.context, logs, &Sequential)
544+
{
545+
Ok(output) => (true, epoch_state.round + 1, Some(output), None),
546+
Err(_) => (
547+
false,
548+
epoch_state.round,
549+
epoch_state.output.clone(),
550+
epoch_state.share.clone(),
551+
),
552+
}
553+
};
560554
if success {
561555
info!(?epoch, "epoch succeeded");
562556
self.successful_epochs.inc();

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,14 @@ mod tests {
340340
let deadline = context.current() + Duration::from_millis(350);
341341
loop {
342342
select! {
343-
msg = tracker_rx.recv() => if let Some(tracker::Message::Dialable { responder }) = msg {
344-
refresh_count += 1;
345-
let _ = responder.send(Dialable {
346-
peers: Vec::new(),
347-
next_query_at: Some(context.current() + Duration::from_millis(100)),
348-
});
343+
msg = tracker_rx.recv() => {
344+
if let Some(tracker::Message::Dialable { responder }) = msg {
345+
refresh_count += 1;
346+
let _ = responder.send(Dialable {
347+
peers: Vec::new(),
348+
next_query_at: Some(context.current() + Duration::from_millis(100)),
349+
});
350+
}
349351
},
350352
_ = context.sleep_until(deadline) => break,
351353
}
@@ -462,12 +464,14 @@ mod tests {
462464
let deadline = context.current() + Duration::from_millis(350);
463465
loop {
464466
select! {
465-
msg = tracker_rx.recv() => if let Some(tracker::Message::Dialable { responder }) = msg {
466-
refresh_count += 1;
467-
let _ = responder.send(Dialable {
468-
peers: Vec::new(),
469-
next_query_at: None,
470-
});
467+
msg = tracker_rx.recv() => {
468+
if let Some(tracker::Message::Dialable { responder }) = msg {
469+
refresh_count += 1;
470+
let _ = responder.send(Dialable {
471+
peers: Vec::new(),
472+
next_query_at: None,
473+
});
474+
}
471475
},
472476
_ = context.sleep_until(deadline) => break,
473477
}

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl<E: Spawner + BufferPooler + Clock + CryptoRngCore + Metrics, C: PublicKey>
160160
}
161161

162162
pub async fn run<O: Sink, I: Stream>(
163-
mut self,
163+
self,
164164
peer: C,
165165
greeting: types::Info<C>,
166166
(mut conn_sender, mut conn_receiver): (Sender<O>, Receiver<I>),
@@ -200,6 +200,7 @@ impl<E: Spawner + BufferPooler + Clock + CryptoRngCore + Metrics, C: PublicKey>
200200

201201
// Enter into the main loop
202202
let mut batch = Vec::with_capacity(self.send_batch_size);
203+
let (control, high, low) = &mut (self.control, self.high, self.low);
203204
select_loop! {
204205
context,
205206
on_stopped => {},
@@ -213,19 +214,32 @@ impl<E: Spawner + BufferPooler + Clock + CryptoRngCore + Metrics, C: PublicKey>
213214
// Await any outbound message (control, high, or low), then
214215
// drain already-queued messages into a single runtime write.
215216
// Priority order: control > high > low.
216-
msg = recv_prioritized(&mut self.control, &mut self.high, &mut self.low) => {
217+
msg = recv_prioritized(control, high, low) => {
217218
let (metric, payload) = match msg {
218219
Prioritized::Closed => return Err(Error::PeerDisconnected),
219-
Prioritized::Control(msg) => Self::prepare_control(&peer, msg, &pool)?,
220-
Prioritized::Data(encoded) => Self::prepare_data(&peer, encoded, &rate_limits),
220+
Prioritized::Control(msg) => {
221+
Self::prepare_control(&peer, msg, &pool)?
222+
}
223+
Prioritized::Data(encoded) => {
224+
Self::prepare_data(&peer, encoded, &rate_limits)
225+
}
221226
};
222227
Self::push_batched(&self.sent_messages, &mut batch, metric, payload);
223228
Self::extend_send_many(
224-
&peer, self.send_batch_size, &mut batch,
225-
&mut self.control, &pool, &mut self.high, &mut self.low,
226-
&rate_limits, &self.sent_messages,
229+
&peer,
230+
self.send_batch_size,
231+
&mut batch,
232+
control,
233+
&pool,
234+
high,
235+
low,
236+
&rate_limits,
237+
&self.sent_messages,
227238
)?;
228-
conn_sender.send_many(batch.drain(..)).await.map_err(Error::SendFailed)?;
239+
conn_sender
240+
.send_many(batch.drain(..))
241+
.await
242+
.map_err(Error::SendFailed)?;
229243
},
230244
}
231245

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,14 @@ mod tests {
342342
let deadline = context.current() + Duration::from_millis(350);
343343
loop {
344344
select! {
345-
msg = tracker_rx.recv() => if let Some(tracker::Message::Dialable { responder }) = msg {
346-
refresh_count += 1;
347-
let _ = responder.send(Dialable {
348-
peers: Vec::new(),
349-
next_query_at: Some(context.current() + Duration::from_millis(100)),
350-
});
345+
msg = tracker_rx.recv() => {
346+
if let Some(tracker::Message::Dialable { responder }) = msg {
347+
refresh_count += 1;
348+
let _ = responder.send(Dialable {
349+
peers: Vec::new(),
350+
next_query_at: Some(context.current() + Duration::from_millis(100)),
351+
});
352+
}
351353
},
352354
_ = context.sleep_until(deadline) => break,
353355
}
@@ -464,12 +466,14 @@ mod tests {
464466
let deadline = context.current() + Duration::from_millis(350);
465467
loop {
466468
select! {
467-
msg = tracker_rx.recv() => if let Some(tracker::Message::Dialable { responder }) = msg {
468-
refresh_count += 1;
469-
let _ = responder.send(Dialable {
470-
peers: Vec::new(),
471-
next_query_at: None,
472-
});
469+
msg = tracker_rx.recv() => {
470+
if let Some(tracker::Message::Dialable { responder }) = msg {
471+
refresh_count += 1;
472+
let _ = responder.send(Dialable {
473+
peers: Vec::new(),
474+
next_query_at: None,
475+
});
476+
}
473477
},
474478
_ = context.sleep_until(deadline) => break,
475479
}

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

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<E: Spawner + BufferPooler + Clock + CryptoRngCore + Metrics, C: PublicKey>
125125
}
126126

127127
pub async fn run<Si: Sink, St: Stream>(
128-
mut self,
128+
self,
129129
peer: C,
130130
(mut conn_sender, mut conn_receiver): (Sender<Si>, Receiver<St>),
131131
channels: Channels<C>,
@@ -158,6 +158,7 @@ impl<E: Spawner + BufferPooler + Clock + CryptoRngCore + Metrics, C: PublicKey>
158158

159159
// Enter into the main loop
160160
let mut batch = Vec::with_capacity(self.send_batch_size);
161+
let (control, high, low) = &mut (self.control, self.high, self.low);
161162
select_loop! {
162163
context,
163164
on_stopped => {},
@@ -171,33 +172,57 @@ impl<E: Spawner + BufferPooler + Clock + CryptoRngCore + Metrics, C: PublicKey>
171172
types::Message::Ping.encode_with_pool(&pool).into(),
172173
);
173174
Self::extend_send_many(
174-
&peer, self.send_batch_size, &mut batch,
175-
&mut self.control, &mut self.high, &mut self.low,
176-
&rate_limits, &self.sent_messages,
175+
&peer,
176+
self.send_batch_size,
177+
&mut batch,
178+
control,
179+
high,
180+
low,
181+
&rate_limits,
182+
&self.sent_messages,
177183
)?;
178-
conn_sender.send_many(batch.drain(..)).await.map_err(Error::SendFailed)?;
184+
conn_sender
185+
.send_many(batch.drain(..))
186+
.await
187+
.map_err(Error::SendFailed)?;
179188
deadline = context.current() + self.ping_frequency;
180189
},
181190
// Await any outbound message (control, high, or low), then
182191
// drain already-queued messages into a single runtime write.
183192
// Priority order: control > high > low.
184-
msg = recv_prioritized(&mut self.control, &mut self.high, &mut self.low) => {
193+
msg = recv_prioritized(control, high, low) => {
185194
match msg {
186195
Prioritized::Closed => return Err(Error::PeerDisconnected),
187196
Prioritized::Control(msg) => match msg {
188-
Message::Kill => return Err(Error::PeerKilled(peer.to_string())),
197+
Message::Kill => {
198+
return Err(Error::PeerKilled(peer.to_string()))
199+
}
189200
},
190201
Prioritized::Data(encoded) => {
191-
let (metric, payload) = Self::prepare_data(&peer, encoded, &rate_limits);
192-
Self::push_batched(&self.sent_messages, &mut batch, metric, payload);
193-
},
202+
let (metric, payload) =
203+
Self::prepare_data(&peer, encoded, &rate_limits);
204+
Self::push_batched(
205+
&self.sent_messages,
206+
&mut batch,
207+
metric,
208+
payload,
209+
);
210+
}
194211
}
195212
Self::extend_send_many(
196-
&peer, self.send_batch_size, &mut batch,
197-
&mut self.control, &mut self.high, &mut self.low,
198-
&rate_limits, &self.sent_messages,
213+
&peer,
214+
self.send_batch_size,
215+
&mut batch,
216+
control,
217+
high,
218+
low,
219+
&rate_limits,
220+
&self.sent_messages,
199221
)?;
200-
conn_sender.send_many(batch.drain(..)).await.map_err(Error::SendFailed)?;
222+
conn_sender
223+
.send_many(batch.drain(..))
224+
.await
225+
.map_err(Error::SendFailed)?;
201226
},
202227
}
203228

0 commit comments

Comments
 (0)