Skip to content

Commit 7706e5a

Browse files
authored
refactor: Rename rem_cid to remote_cid and friends (#351)
* refactor: Rename `rem_cid` to `remote_cid` and friends * `cargo make format`
1 parent 9f4c68e commit 7706e5a

File tree

8 files changed

+120
-108
lines changed

8 files changed

+120
-108
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 77 additions & 69 deletions
Large diffs are not rendered by default.

quinn-proto/src/connection/qlog.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ impl QlogSink {
144144
pub(crate) fn emit_connection_started(
145145
&self,
146146
now: Instant,
147-
loc_cid: ConnectionId,
148-
rem_cid: ConnectionId,
147+
local_cid: ConnectionId,
148+
remote_cid: ConnectionId,
149149
remote: SocketAddr,
150150
local_ip: Option<IpAddr>,
151151
transport_params: &TransportParameters,
@@ -157,11 +157,11 @@ impl QlogSink {
157157
};
158158
stream.emit_event(
159159
EventData::ConnectionStarted(ConnectionStarted {
160-
local: tuple_endpoint_info(local_ip, None, Some(loc_cid)),
160+
local: tuple_endpoint_info(local_ip, None, Some(local_cid)),
161161
remote: tuple_endpoint_info(
162162
Some(remote.ip()),
163163
Some(remote.port()),
164-
Some(rem_cid),
164+
Some(remote_cid),
165165
),
166166
}),
167167
now,

quinn-proto/src/connection/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ pub struct Handshake {
330330
/// Whether the remote CID has been set by the peer yet.
331331
///
332332
/// Always set for servers.
333-
pub(super) rem_cid_set: bool,
333+
pub(super) remote_cid_set: bool,
334334
/// Stateless retry token received in the first Initial by a server.
335335
///
336336
/// Must be present in every Initial. Always empty for clients.

quinn-proto/src/endpoint.rs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Endpoint {
118118
}
119119
RetireConnectionId(now, path_id, seq, allow_more_cids) => {
120120
if let Some(cid) = self.connections[ch]
121-
.loc_cids
121+
.local_cids
122122
.get_mut(&path_id)
123123
.and_then(|pcid| pcid.cids.remove(&seq))
124124
{
@@ -348,12 +348,12 @@ impl Endpoint {
348348
trace!(initial_dcid = %remote_id);
349349

350350
let ch = ConnectionHandle(self.connections.vacant_key());
351-
let loc_cid = self.new_cid(ch, PathId::ZERO);
351+
let local_cid = self.new_cid(ch, PathId::ZERO);
352352
let params = TransportParameters::new(
353353
&config.transport,
354354
&self.config,
355355
self.local_cid_generator.as_ref(),
356-
loc_cid,
356+
local_cid,
357357
None,
358358
&mut self.rng,
359359
);
@@ -365,7 +365,7 @@ impl Endpoint {
365365
ch,
366366
config.version,
367367
remote_id,
368-
loc_cid,
368+
local_cid,
369369
remote_id,
370370
FourTuple {
371371
remote,
@@ -394,7 +394,7 @@ impl Endpoint {
394394
let mut ids = vec![];
395395
for _ in 0..num {
396396
let id = self.new_cid(ch, path_id);
397-
let cid_meta = self.connections[ch].loc_cids.entry(path_id).or_default();
397+
let cid_meta = self.connections[ch].local_cids.entry(path_id).or_default();
398398
let sequence = cid_meta.issued;
399399
cid_meta.issued += 1;
400400
cid_meta.cids.insert(sequence, id);
@@ -606,16 +606,16 @@ impl Endpoint {
606606
};
607607

608608
let ch = ConnectionHandle(self.connections.vacant_key());
609-
let loc_cid = self.new_cid(ch, PathId::ZERO);
609+
let local_cid = self.new_cid(ch, PathId::ZERO);
610610
let mut params = TransportParameters::new(
611611
&server_config.transport,
612612
&self.config,
613613
self.local_cid_generator.as_ref(),
614-
loc_cid,
614+
local_cid,
615615
Some(&server_config),
616616
&mut self.rng,
617617
);
618-
params.stateless_reset_token = Some(ResetToken::new(&*self.config.reset_key, loc_cid));
618+
params.stateless_reset_token = Some(ResetToken::new(&*self.config.reset_key, local_cid));
619619
params.original_dst_cid = Some(incoming.token.orig_dst_cid);
620620
params.retry_src_cid = incoming.token.retry_src_cid;
621621
let mut pref_addr_cid = None;
@@ -636,7 +636,7 @@ impl Endpoint {
636636
ch,
637637
version,
638638
dst_cid,
639-
loc_cid,
639+
local_cid,
640640
src_cid,
641641
incoming.network_path,
642642
incoming.received_at,
@@ -751,7 +751,7 @@ impl Endpoint {
751751
// with established connections. In the unlikely event that a collision occurs
752752
// between two connections in the initial phase, both will fail fast and may be
753753
// retried by the application layer.
754-
let loc_cid = self.local_cid_generator.generate_cid();
754+
let local_cid = self.local_cid_generator.generate_cid();
755755

756756
let payload = TokenPayload::Retry {
757757
address: incoming.network_path.remote,
@@ -761,7 +761,7 @@ impl Endpoint {
761761
let token = Token::new(payload, &mut self.rng).encode(&*server_config.token_key);
762762

763763
let header = Header::Retry {
764-
src_cid: loc_cid,
764+
src_cid: local_cid,
765765
dst_cid: incoming.packet.header.src_cid,
766766
version: incoming.packet.header.version,
767767
};
@@ -805,8 +805,8 @@ impl Endpoint {
805805
ch: ConnectionHandle,
806806
version: u32,
807807
init_cid: ConnectionId,
808-
loc_cid: ConnectionId,
809-
rem_cid: ConnectionId,
808+
local_cid: ConnectionId,
809+
remote_cid: ConnectionId,
810810
network_path: FourTuple,
811811
now: Instant,
812812
tls: Box<dyn crypto::Session>,
@@ -825,8 +825,8 @@ impl Endpoint {
825825

826826
qlog.emit_connection_started(
827827
now,
828-
loc_cid,
829-
rem_cid,
828+
local_cid,
829+
remote_cid,
830830
network_path.remote,
831831
network_path.local_ip,
832832
params,
@@ -836,8 +836,8 @@ impl Endpoint {
836836
self.config.clone(),
837837
transport_config,
838838
init_cid,
839-
loc_cid,
840-
rem_cid,
839+
local_cid,
840+
remote_cid,
841841
network_path,
842842
tls,
843843
self.local_cid_generator.as_ref(),
@@ -850,7 +850,7 @@ impl Endpoint {
850850
);
851851

852852
let mut path_cids = PathLocalCids::default();
853-
path_cids.cids.insert(path_cids.issued, loc_cid);
853+
path_cids.cids.insert(path_cids.issued, local_cid);
854854
path_cids.issued += 1;
855855

856856
if let Some(cid) = pref_addr_cid {
@@ -861,14 +861,14 @@ impl Endpoint {
861861

862862
let id = self.connections.insert(ConnectionMeta {
863863
init_cid,
864-
loc_cids: FxHashMap::from_iter([(PathId::ZERO, path_cids)]),
864+
local_cids: FxHashMap::from_iter([(PathId::ZERO, path_cids)]),
865865
network_path,
866866
side,
867867
reset_token: Default::default(),
868868
});
869869
debug_assert_eq!(id, ch.0, "connection handle allocation out of sync");
870870

871-
self.index.insert_conn(network_path, loc_cid, ch, side);
871+
self.index.insert_conn(network_path, local_cid, ch, side);
872872

873873
conn
874874
}
@@ -1093,7 +1093,11 @@ impl ConnectionIndex {
10931093
if conn.side.is_server() {
10941094
self.remove_initial(conn.init_cid);
10951095
}
1096-
for cid in conn.loc_cids.values().flat_map(|pcids| pcids.cids.values()) {
1096+
for cid in conn
1097+
.local_cids
1098+
.values()
1099+
.flat_map(|pcids| pcids.cids.values())
1100+
{
10971101
self.connection_ids.remove(cid);
10981102
}
10991103
self.incoming_connection_remotes.remove(&conn.network_path);
@@ -1144,7 +1148,7 @@ impl ConnectionIndex {
11441148
pub(crate) struct ConnectionMeta {
11451149
init_cid: ConnectionId,
11461150
/// Locally issues CIDs for each path
1147-
loc_cids: FxHashMap<PathId, PathLocalCids>,
1151+
local_cids: FxHashMap<PathId, PathLocalCids>,
11481152
/// Remote/local addresses the connection began with
11491153
///
11501154
/// Only needed to support connections with zero-length CIDs, which cannot migrate, so we don't

quinn-proto/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ pub struct Transmit {
351351
//
352352

353353
/// The maximum number of CIDs we bother to issue per path
354-
const LOC_CID_COUNT: u64 = 12;
354+
const LOCAL_CID_COUNT: u64 = 12;
355355
const RESET_TOKEN_SIZE: usize = 16;
356356
const MAX_CID_SIZE: usize = 20;
357357
const MIN_INITIAL_SIZE: u16 = 1200;

quinn-proto/src/tests/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,9 +1702,9 @@ fn cid_rotation() {
17021702
let mut stop = pair.time;
17031703
let end = pair.time + 5 * CID_TIMEOUT;
17041704

1705-
use crate::{LOC_CID_COUNT, cid_queue::CidQueue};
1705+
use crate::{LOCAL_CID_COUNT, cid_queue::CidQueue};
17061706
let mut active_cid_num = CidQueue::LEN as u64 + 1;
1707-
active_cid_num = active_cid_num.min(LOC_CID_COUNT);
1707+
active_cid_num = active_cid_num.min(LOCAL_CID_COUNT);
17081708
let mut left_bound = 0;
17091709
let mut right_bound = active_cid_num - 1;
17101710

@@ -1747,11 +1747,11 @@ fn cid_retirement() {
17471747
// Any unexpected behavior may trigger TransportError::CONNECTION_ID_LIMIT_ERROR
17481748
assert!(!pair.client_conn_mut(client_ch).is_closed());
17491749
assert!(!pair.server_conn_mut(server_ch).is_closed());
1750-
assert_matches!(pair.client_conn_mut(client_ch).active_rem_cid_seq(), 1);
1750+
assert_matches!(pair.client_conn_mut(client_ch).active_remote_cid_seq(), 1);
17511751

1752-
use crate::{LOC_CID_COUNT, cid_queue::CidQueue};
1752+
use crate::{LOCAL_CID_COUNT, cid_queue::CidQueue};
17531753
let mut active_cid_num = CidQueue::LEN as u64;
1754-
active_cid_num = active_cid_num.min(LOC_CID_COUNT);
1754+
active_cid_num = active_cid_num.min(LOCAL_CID_COUNT);
17551755

17561756
let now = pair.time;
17571757
let next_retire_prior_to = active_cid_num + 1;
@@ -1764,7 +1764,7 @@ fn cid_retirement() {
17641764
assert!(!pair.server_conn_mut(server_ch).is_closed());
17651765

17661766
assert_eq!(
1767-
pair.client_conn_mut(client_ch).active_rem_cid_seq(),
1767+
pair.client_conn_mut(client_ch).active_remote_cid_seq(),
17681768
next_retire_prior_to,
17691769
);
17701770
}

quinn-proto/src/tests/multipath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::tests::RoutingTable;
1212
use crate::tests::util::{CLIENT_PORTS, SERVER_PORTS};
1313
use crate::{
1414
ClientConfig, ClosePathError, ConnectionHandle, ConnectionId, ConnectionIdGenerator, Endpoint,
15-
EndpointConfig, FourTuple, LOC_CID_COUNT, PathId, PathStatus, RandomConnectionIdGenerator,
15+
EndpointConfig, FourTuple, LOCAL_CID_COUNT, PathId, PathStatus, RandomConnectionIdGenerator,
1616
ServerConfig, TransportConfig, cid_queue::CidQueue,
1717
};
1818
use crate::{Event, PathError, PathEvent};
@@ -238,7 +238,7 @@ fn multipath_cid_rotation() {
238238
let end = pair.time + 5 * CID_TIMEOUT;
239239

240240
let mut active_cid_num = CidQueue::LEN as u64 + 1;
241-
active_cid_num = active_cid_num.min(LOC_CID_COUNT);
241+
active_cid_num = active_cid_num.min(LOCAL_CID_COUNT);
242242
let mut left_bound = 0;
243243
let mut right_bound = active_cid_num - 1;
244244

quinn-proto/src/transport_parameters.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rand::{Rng as _, RngCore, seq::SliceRandom as _};
1717
use thiserror::Error;
1818

1919
use crate::{
20-
LOC_CID_COUNT, MAX_CID_SIZE, MAX_STREAM_COUNT, RESET_TOKEN_SIZE, ResetToken, Side,
20+
LOCAL_CID_COUNT, MAX_CID_SIZE, MAX_STREAM_COUNT, RESET_TOKEN_SIZE, ResetToken, Side,
2121
TIMER_GRANULARITY, TransportError, VarInt, address_discovery,
2222
cid_generator::ConnectionIdGenerator,
2323
cid_queue::CidQueue,
@@ -227,9 +227,9 @@ impl TransportParameters {
227227
/// Maximum number of CIDs to issue to this peer
228228
///
229229
/// Consider both a) the active_connection_id_limit from the other end; and
230-
/// b) LOC_CID_COUNT used locally
230+
/// b) LOCAL_CID_COUNT used locally
231231
pub(crate) fn issue_cids_limit(&self) -> u64 {
232-
self.active_connection_id_limit.0.min(LOC_CID_COUNT)
232+
self.active_connection_id_limit.0.min(LOCAL_CID_COUNT)
233233
}
234234
}
235235

0 commit comments

Comments
 (0)