1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/// Configuration for the entangler.
#[derive(Debug, Clone)]
pub struct Config {
/// The number of parity chunks to generate for each data chunk.
pub alpha: u8,
/// The number of horizontal strands in the grid.
pub s: u8,
/// The number of helical strands in the grid.
pub p: u8,
/// Specifies whether to always try to heal blobs.
/// If set to `false`, the entangler will try to repair and consequently upload the entire blob
/// only when the whole blob was requested.
/// To make it try to heal and upload the blob also when only a part of it was requested
/// (e.g. with range request), set this to `true`.
/// Default is `true`.
pub always_repair: bool,
}
impl Default for Config {
fn default() -> Self {
Self {
alpha: 3,
s: 5,
p: 5,
always_repair: true,
}
}
}
impl Config {
/// Creates a new `Config` with the given parameters. The reset of the parameters are set to
/// their default values.
///
/// # Arguments
///
/// * `alpha` - The number of parity chunks to generate for each data chunk.
/// * `s` - The number of horizontal strands in the grid.
/// * `p` - The number of helical strands in the grid.
///
/// # Returns
///
/// A new `Config` with the given parameters.
pub fn new(alpha: u8, s: u8, p: u8) -> Self {
Config {
alpha,
s,
p,
..Default::default()
}
}
}