channel padding: Make Parameters a pub struct with builder
chanmgr is going to want to make one of these from a NetDir.
This commit is contained in:
parent
db4ea619f5
commit
7135b7c4c7
|
@ -3869,6 +3869,7 @@ dependencies = [
|
|||
"bytes",
|
||||
"cipher",
|
||||
"coarsetime",
|
||||
"derive_builder_fork_arti",
|
||||
"digest 0.10.3",
|
||||
"educe",
|
||||
"futures",
|
||||
|
|
|
@ -25,6 +25,7 @@ asynchronous-codec = "0.6.0"
|
|||
bytes = "1"
|
||||
cipher = "0.4.1"
|
||||
coarsetime = "0.1.20"
|
||||
derive_builder = { version = "0.11.2", package = "derive_builder_fork_arti" }
|
||||
digest = "0.10.0"
|
||||
educe = "0.4.6"
|
||||
futures = "0.3.14"
|
||||
|
|
|
@ -59,7 +59,7 @@ pub const CHANNEL_BUFFER_SIZE: usize = 128;
|
|||
mod circmap;
|
||||
mod codec;
|
||||
mod handshake;
|
||||
mod padding;
|
||||
pub mod padding;
|
||||
mod reactor;
|
||||
mod unique_id;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use std::pin::Pin;
|
|||
// TODO, coarsetime maybe? But see arti#496 and also we want to use the mockable SleepProvider
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use derive_builder::Builder;
|
||||
use educe::Educe;
|
||||
use futures::future::{self, FusedFuture};
|
||||
use futures::FutureExt;
|
||||
|
@ -91,14 +92,24 @@ pub(crate) struct Timer<R: SleepProvider> {
|
|||
}
|
||||
|
||||
/// Timing parameters, as described in `padding-spec.txt`
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub(crate) struct Parameters {
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Builder)]
|
||||
pub struct Parameters {
|
||||
/// Low end of the distribution of `X`
|
||||
#[builder(default = "1500")]
|
||||
pub(crate) low_ms: u32,
|
||||
/// High end of the distribution of `X` (inclusive)
|
||||
#[builder(default = "9500")]
|
||||
pub(crate) high_ms: u32,
|
||||
}
|
||||
|
||||
impl Default for Parameters {
|
||||
fn default() -> Self {
|
||||
ParametersBuilder::default()
|
||||
.build()
|
||||
.expect("could not build default channel padding Parameters")
|
||||
}
|
||||
}
|
||||
|
||||
/// Timing parameters, "compiled" into a form which can be sampled more efficiently
|
||||
///
|
||||
/// According to the docs for [`rand::Rng::gen_range`],
|
||||
|
|
Loading…
Reference in New Issue