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
#[macro_export]
macro_rules! fatal {
($($t:tt)*) => {{
let m = format!($($t)*);
eprintln!("{}", &m);
panic!("{}", m);
}};
}
#[macro_export]
macro_rules! fatal_db_hash_construction_check {
($hint:expr, $hash:expr, $res:expr,) => {
fatal_db_hash_construction_check!($hint, $hash, $res);
};
($hint:expr, $hash:expr, $res:expr) => {{
match $res {
Ok(res) => res,
Err(e) => {
$crate::fatal!(
r#"Holochain detected database corruption.
Corrupt module: {}
Expected hash: {:?}
Deserialization Error: {:?}
We are shutting down as a precaution to prevent further corruption."#,
$hint,
$hash,
e,
);
}
}
}};
}
#[macro_export]
macro_rules! fatal_db_hash_integrity_check {
($hint:expr, $expected_hash:expr, $actual_hash:expr, $content:expr $(,)?) => {
if *$expected_hash != *$actual_hash {
$crate::fatal!(
r#"Holochain detected database corruption.
Corrupt module: {}
Expected hash: {:?}
Actual hash: {:?}
Content: {:?}
We are shutting down as a precaution to prevent further corruption."#,
$hint,
$expected_hash,
$actual_hash,
$content,
);
}
};
}