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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
use crate::genesis_block_params::ParseParamsError;
use serde::{Deserialize, Serialize};
#[derive(Debug, Copy, Clone, Deserialize, Serialize, PartialEq)]
pub struct BlockV10Parameters {
pub c: f64,
pub dt: u64,
pub ud0: usize,
pub sig_period: u64,
pub sig_stock: usize,
pub sig_window: u64,
pub sig_validity: u64,
pub sig_qty: usize,
pub idty_window: u64,
pub ms_window: u64,
pub x_percent: f64,
pub ms_validity: u64,
pub step_max: usize,
pub median_time_blocks: usize,
pub avg_gen_time: u64,
pub dt_diff_eval: usize,
pub percent_rot: f64,
pub ud_time0: u64,
pub ud_reeval_time0: u64,
pub dt_reeval: u64,
}
impl Default for BlockV10Parameters {
fn default() -> BlockV10Parameters {
BlockV10Parameters {
c: 0.0488,
dt: 86_400,
ud0: 1_000,
sig_period: 432_000,
sig_stock: 100,
sig_window: 5_259_600,
sig_validity: 63_115_200,
sig_qty: 5,
idty_window: 5_259_600,
ms_window: 5_259_600,
x_percent: 0.8,
ms_validity: 31_557_600,
step_max: 5,
median_time_blocks: 24,
avg_gen_time: 300,
dt_diff_eval: 12,
percent_rot: 0.67,
ud_time0: 1_488_970_800,
ud_reeval_time0: 1_490_094_000,
dt_reeval: 15_778_800,
}
}
}
impl ::std::str::FromStr for BlockV10Parameters {
type Err = ParseParamsError;
fn from_str(source: &str) -> Result<Self, Self::Err> {
let params: Vec<&str> = source.split(':').collect();
Ok(BlockV10Parameters {
c: params[0].parse()?,
dt: params[1].parse()?,
ud0: params[2].parse()?,
sig_period: params[3].parse()?,
sig_stock: params[4].parse()?,
sig_window: params[5].parse()?,
sig_validity: params[6].parse()?,
sig_qty: params[7].parse()?,
idty_window: params[8].parse()?,
ms_window: params[9].parse()?,
x_percent: params[10].parse()?,
ms_validity: params[11].parse()?,
step_max: params[12].parse()?,
median_time_blocks: params[13].parse()?,
avg_gen_time: params[14].parse()?,
dt_diff_eval: params[15].parse()?,
percent_rot: params[16].parse()?,
ud_time0: params[17].parse()?,
ud_reeval_time0: params[18].parse()?,
dt_reeval: params[19].parse()?,
})
}
}
impl ToString for BlockV10Parameters {
fn to_string(&self) -> String {
format!(
"{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}:{}",
self.c,
self.dt,
self.ud0,
self.sig_period,
self.sig_stock,
self.sig_window,
self.sig_validity,
self.sig_qty,
self.idty_window,
self.ms_window,
self.x_percent,
self.ms_validity,
self.step_max,
self.median_time_blocks,
self.avg_gen_time,
self.dt_diff_eval,
self.percent_rot,
self.ud_time0,
self.ud_reeval_time0,
self.dt_reeval,
)
}
}
impl Eq for BlockV10Parameters {}