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
crate::ix!();
#[derive(Default,Serialize,Deserialize)]
pub struct BlockFileInfo {
pub n_blocks: u32,
pub n_size: u32,
pub n_undo_size: u32,
pub n_height_first: u32,
pub n_height_last: u32,
pub n_time_first: u64,
pub n_time_last: u64,
}
impl BlockFileInfo {
pub fn set_null(&mut self) {
self.n_blocks = 0;
self.n_size = 0;
self.n_undo_size = 0;
self.n_height_first = 0;
self.n_height_last = 0;
self.n_time_first = 0;
self.n_time_last = 0;
}
pub fn add_block(&mut self,
n_height_in: u32,
n_time_in: u64) {
if self.n_blocks == 0 || self.n_height_first > n_height_in {
self.n_height_first = n_height_in;
}
if self.n_blocks == 0 || self.n_time_first > n_time_in {
self.n_time_first = n_time_in;
}
self.n_blocks += 1;
if n_height_in > self.n_height_last {
self.n_height_last = n_height_in;
}
if n_time_in > self.n_time_last {
self.n_time_last = n_time_in;
}
}
pub fn to_string(&self) -> String {
format!(
"BlockFileInfo(blocks={}, size={}, heights={}...{}, time={}...{})",
self.n_blocks,
self.n_size,
self.n_height_first,
self.n_height_last,
format_iso8601date(self.n_time_first.try_into().unwrap()),
format_iso8601date(self.n_time_last.try_into().unwrap())
)
}
}