channel padding: Rename low_ms and high_ms
These have the unit in the type. Putting that in the field name too is otiose.
This commit is contained in:
parent
18a6234101
commit
7ed983800d
|
@ -867,7 +867,11 @@ impl PaddingNegotiate {
|
|||
/// For testing only
|
||||
#[cfg(feature = "testing")]
|
||||
pub fn from_raw(command: PaddingNegotiateCmd, ito_low_ms: u16, ito_high_ms: u16) -> Self {
|
||||
PaddingNegotiate { command, ito_low_ms, ito_high_ms, }
|
||||
PaddingNegotiate {
|
||||
command,
|
||||
ito_low_ms,
|
||||
ito_high_ms,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Default for PaddingNegotiate {
|
||||
|
|
|
@ -514,8 +514,8 @@ fn padding_parameters(
|
|||
if low > high {
|
||||
return Err("low > high");
|
||||
}
|
||||
p.low_ms(low);
|
||||
p.high_ms(high);
|
||||
p.low(low);
|
||||
p.high(high);
|
||||
Ok::<_, &'static str>(())
|
||||
})()
|
||||
.unwrap_or_else(|e| {
|
||||
|
@ -739,7 +739,7 @@ mod test {
|
|||
.start_update()
|
||||
.padding_parameters(
|
||||
PaddingParametersBuilder::default()
|
||||
.low_ms(1234.into())
|
||||
.low(1234.into())
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
|
@ -767,8 +767,8 @@ mod test {
|
|||
// evade field visibility by (ab)using Debug impl
|
||||
"ChannelsParamsUpdates { padding_enable: None, \
|
||||
padding_parameters: Some(Parameters { \
|
||||
low_ms: IntegerMilliseconds { value: 1500 }, \
|
||||
high_ms: IntegerMilliseconds { value: 9500 } }), \
|
||||
low: IntegerMilliseconds { value: 1500 }, \
|
||||
high: IntegerMilliseconds { value: 9500 } }), \
|
||||
padding_negotiate: None }"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -69,8 +69,8 @@ fn padding_parameters_calculation() {
|
|||
);
|
||||
let got = padding_parameters(pconfig, netdir).unwrap();
|
||||
let exp = PaddingParameters::builder()
|
||||
.low_ms(exp[0].into())
|
||||
.high_ms(exp[1].into())
|
||||
.low(exp[0].into())
|
||||
.high(exp[1].into())
|
||||
.build()
|
||||
.unwrap();
|
||||
assert_eq!(got, exp);
|
||||
|
@ -202,8 +202,8 @@ impl CaseContext {
|
|||
nego.map(|(cmd, [low, high])| PaddingNegotiate::from_raw(cmd, low as _, high as _));
|
||||
let timing = timing.map(|[low, high]| {
|
||||
PaddingParameters::builder()
|
||||
.low_ms(low.into())
|
||||
.high_ms(high.into())
|
||||
.low(low.into())
|
||||
.high(high.into())
|
||||
.build()
|
||||
.unwrap()
|
||||
});
|
||||
|
|
|
@ -126,10 +126,10 @@ pub(crate) struct Timer<R: SleepProvider> {
|
|||
pub struct Parameters {
|
||||
/// Low end of the distribution of `X`
|
||||
#[builder(default = "1500.into()")]
|
||||
pub(crate) low_ms: IntegerMilliseconds<u32>,
|
||||
pub(crate) low: IntegerMilliseconds<u32>,
|
||||
/// High end of the distribution of `X` (inclusive)
|
||||
#[builder(default = "9500.into()")]
|
||||
pub(crate) high_ms: IntegerMilliseconds<u32>,
|
||||
pub(crate) high: IntegerMilliseconds<u32>,
|
||||
}
|
||||
|
||||
impl_standard_builder! { Parameters: !Deserialize + !Builder }
|
||||
|
@ -140,8 +140,8 @@ impl Parameters {
|
|||
/// As per `torspec/padding-spec.txt` section 2.6
|
||||
pub fn default_reduced() -> Self {
|
||||
Parameters {
|
||||
low_ms: IntegerMilliseconds::new(9000),
|
||||
high_ms: IntegerMilliseconds::new(14000),
|
||||
low: IntegerMilliseconds::new(9000),
|
||||
high: IntegerMilliseconds::new(14000),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ impl Parameters {
|
|||
.try_into()
|
||||
.map_err(into_internal!("padding negotiate out of range"))
|
||||
};
|
||||
Ok(PaddingNegotiate::start(get(self.low_ms)?, get(self.high_ms)?))
|
||||
Ok(PaddingNegotiate::start(get(self.low)?, get(self.high)?))
|
||||
}
|
||||
|
||||
/// Make a Parameters sentinel value, with both fields set to zero
|
||||
|
@ -165,8 +165,8 @@ impl Parameters {
|
|||
/// The specification says to treat this as disabled, if found in the consensus.
|
||||
pub fn all_zeroes() -> Self {
|
||||
Parameters {
|
||||
low_ms: 0.into(),
|
||||
high_ms: 0.into(),
|
||||
low: 0.into(),
|
||||
high: 0.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -389,8 +389,8 @@ impl Parameters {
|
|||
fn prepare(self) -> PreparedParameters {
|
||||
PreparedParameters {
|
||||
x_distribution_ms: rand::distributions::Uniform::new_inclusive(
|
||||
self.low_ms.as_millis(),
|
||||
self.high_ms.as_millis(),
|
||||
self.low.as_millis(),
|
||||
self.high.as_millis(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -448,8 +448,8 @@ mod test {
|
|||
let runtime = tor_rtmock::MockSleepRuntime::new(runtime);
|
||||
|
||||
let parameters = Parameters {
|
||||
low_ms: 1000.into(),
|
||||
high_ms: 1000.into(),
|
||||
low: 1000.into(),
|
||||
high: 1000.into(),
|
||||
};
|
||||
|
||||
let () = runtime.block_on(async {
|
||||
|
@ -617,8 +617,8 @@ mod test {
|
|||
let mut obs = [0_u32; n];
|
||||
|
||||
let params = Parameters {
|
||||
low_ms: min.into(),
|
||||
high_ms: (max - 1).into(), // convert exclusive to inclusive
|
||||
low: min.into(),
|
||||
high: (max - 1).into(), // convert exclusive to inclusive
|
||||
}
|
||||
.prepare();
|
||||
|
||||
|
|
Loading…
Reference in New Issue