Skip to content

Commit b26972b

Browse files
committed
lint: run cargo fmt
1 parent 16263ec commit b26972b

8 files changed

Lines changed: 59 additions & 44 deletions

File tree

crates/cac/types/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
//! to ever interact with directly, so this can have types that we don't want to
55
//! expose in the RPC interface (or be compiled into RPC libraries).
66
7-
pub use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
8-
97
// Used by examples
108
use ark_ec as _;
119
use ark_ff as _;
12-
10+
pub use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
1311
// Used by benchmarks
1412
#[cfg(test)]
1513
use criterion as _;

crates/net/svc/src/api.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use std::sync::Arc;
88

99
use kanal::{AsyncReceiver, AsyncSender};
1010

11-
use crate::config::NetServiceConfig;
12-
use crate::tls::PeerId;
11+
use crate::{config::NetServiceConfig, tls::PeerId};
1312

1413
/// A buffer for payload data.
1514
///
@@ -315,8 +314,8 @@ impl NetServiceHandle {
315314
/// # Arguments
316315
///
317316
/// * `peer` - The peer to open the stream to (must be in config).
318-
/// * `priority` - Stream priority. Higher = more important. Use 0 for normal,
319-
/// 1 for high (ACKs), -1 for low.
317+
/// * `priority` - Stream priority. Higher = more important. Use 0 for normal, 1 for high
318+
/// (ACKs), -1 for low.
320319
pub async fn open_protocol_stream(
321320
&self,
322321
peer: PeerId,

crates/net/svc/src/svc/handlers.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
1515
use kanal::{AsyncReceiver, bounded_async};
1616

17-
use crate::api::{ExpectError, NetCommand, OpenStreamError, Stream};
18-
use crate::tls::PeerId;
19-
20-
use super::state::{
21-
ConnectionDirection, PendingStreamRequest, ServiceEvent, ServiceState, TrackedConnection,
17+
use super::{
18+
state::{
19+
ConnectionDirection, PendingStreamRequest, ServiceEvent, ServiceState, TrackedConnection,
20+
},
21+
tasks,
22+
};
23+
use crate::{
24+
api::{ExpectError, NetCommand, OpenStreamError, Stream},
25+
tls::PeerId,
2226
};
23-
use super::tasks;
2427

2528
/// Handle a command from a NetServiceHandle.
2629
///

crates/net/svc/src/svc/mod.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,24 @@ mod state;
2424
mod stream;
2525
mod tasks;
2626

27-
use std::collections::HashSet;
28-
use std::sync::Arc;
29-
use std::thread::{self, JoinHandle};
30-
use std::time::Duration;
27+
use std::{
28+
collections::HashSet,
29+
sync::Arc,
30+
thread::{self, JoinHandle},
31+
time::Duration,
32+
};
3133

3234
use ahash::{HashMap, HashMapExt};
3335
use kanal::{AsyncReceiver, AsyncSender, bounded_async};
3436
use quinn::{Endpoint, ServerConfig};
37+
use state::{ServiceEvent, ServiceState, TrackedConnection};
3538
use tokio::runtime::Builder;
3639

37-
use crate::api::{NetCommand, NetServiceHandle, Stream};
38-
use crate::config::NetServiceConfig;
39-
use crate::tls::{self, PeerId};
40-
41-
use state::{ServiceEvent, ServiceState, TrackedConnection};
40+
use crate::{
41+
api::{NetCommand, NetServiceHandle, Stream},
42+
config::NetServiceConfig,
43+
tls::{self, PeerId},
44+
};
4245

4346
/// Handle to control the network service.
4447
pub struct NetServiceController {

crates/net/svc/src/svc/state.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
//! This module contains the service state, internal events, and helper types
44
//! used by the main loop and handlers.
55
6-
use std::sync::Arc;
7-
use std::time::Duration;
6+
use std::{sync::Arc, time::Duration};
87

98
use ahash::HashMap;
109
use kanal::AsyncSender;
1110
use quinn::Endpoint;
1211

13-
use crate::api::{OpenStreamError, Stream};
14-
use crate::config::NetServiceConfig;
15-
use crate::tls::PeerId;
12+
use crate::{
13+
api::{OpenStreamError, Stream},
14+
config::NetServiceConfig,
15+
tls::PeerId,
16+
};
1617

1718
/// Direction metadata for a stored connection.
1819
///

crates/net/svc/src/svc/stream.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ use std::sync::{Arc, Mutex};
88
use kanal::{AsyncReceiver, AsyncSender, bounded_async};
99
use quinn::{RecvStream, SendStream};
1010

11-
use crate::api::{PayloadBuf, Stream, StreamClosed, StreamRequest};
12-
use crate::tls::PeerId;
11+
use crate::{
12+
api::{PayloadBuf, Stream, StreamClosed, StreamRequest},
13+
tls::PeerId,
14+
};
1315

1416
/// Channel buffer sizes for stream communication.
1517
const PAYLOAD_CHANNEL_SIZE: usize = 16;
@@ -94,7 +96,9 @@ async fn write_task(
9496
StreamRequest::Write { buf } => {
9597
// Encode frame with length prefix
9698
frame_buf.clear();
97-
if let Err(e) = mosaic_net_wire::encode_frame_unchecked(&buf, &mut frame_buf) {
99+
if let Err(e) =
100+
mosaic_net_wire::encode_frame_unchecked(&buf, &mut frame_buf)
101+
{
98102
tracing::warn!(error = %e, "failed to encode frame");
99103
// Return buffer anyway
100104
let mut buf = buf;

crates/net/svc/src/svc/tasks.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ use std::{collections::HashSet, sync::Arc};
1313
use kanal::AsyncSender;
1414
use quinn::Endpoint;
1515

16-
use crate::api::{OpenStreamError, Stream};
17-
use crate::tls::PeerId;
18-
19-
use super::conn;
20-
use super::state::{CONNECTION_TIMEOUT, HEADER_READ_TIMEOUT, ServiceEvent};
21-
use super::stream;
16+
use super::{
17+
conn,
18+
state::{CONNECTION_TIMEOUT, HEADER_READ_TIMEOUT, ServiceEvent},
19+
stream,
20+
};
21+
use crate::{
22+
api::{OpenStreamError, Stream},
23+
tls::PeerId,
24+
};
2225

2326
/// Spawn a task to handle an incoming connection's TLS handshake.
2427
///
@@ -216,8 +219,8 @@ pub fn spawn_stream_header_reader(
216219
}
217220

218221
// Decode header
219-
let (header, _) =
220-
mosaic_net_wire::StreamHeader::decode(&buf[..1 + remaining]).map_err(|e| e.to_string())?;
222+
let (header, _) = mosaic_net_wire::StreamHeader::decode(&buf[..1 + remaining])
223+
.map_err(|e| e.to_string())?;
221224

222225
Ok(header.stream_type)
223226
}

crates/net/svc/tests/integration.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
//! That is inherently flaky in CI. Prefer waiting for an actual successful
88
//! operation with a timeout.
99
10-
use std::net::SocketAddr;
11-
use std::sync::Once;
12-
use std::sync::atomic::{AtomicU16, Ordering};
13-
use std::time::Duration;
10+
use std::{
11+
net::SocketAddr,
12+
sync::{
13+
Once,
14+
atomic::{AtomicU16, Ordering},
15+
},
16+
time::Duration,
17+
};
1418

1519
use ed25519_dalek::SigningKey;
1620
use mosaic_net_svc::{
@@ -168,8 +172,8 @@ where
168172
/// Receive a value with a timeout.
169173
///
170174
/// This is intentionally *not* a retry loop:
171-
/// - If the channel is open but no value arrives, `recv().await` may wait indefinitely,
172-
/// so we bound it with a timeout.
175+
/// - If the channel is open but no value arrives, `recv().await` may wait indefinitely, so we bound
176+
/// it with a timeout.
173177
/// - If the channel is closed, `recv().await` should return promptly with an error.
174178
/// - If the value is merely delayed, increasing the timeout is the right fix (not retries).
175179
async fn recv_with_timeout<Fut, T>(timeout: Duration, fut: Fut) -> T

0 commit comments

Comments
 (0)