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
use bitflags::bitflags;
use ckb_error::Error;
pub trait Verifier {
type Target;
fn verify(&self, target: &Self::Target) -> Result<(), Error>;
}
bitflags! {
pub struct Switch: u32 {
const NONE = 0b00000000;
const DISABLE_EPOCH = 0b00000001;
const DISABLE_UNCLES = 0b00000010;
const DISABLE_TWO_PHASE_COMMIT = 0b00000100;
const DISABLE_DAOHEADER = 0b00001000;
const DISABLE_REWARD = 0b00010000;
const DISABLE_NON_CONTEXTUAL = 0b00100000;
const DISABLE_SCRIPT = 0b01000000;
const DISABLE_ALL = Self::DISABLE_EPOCH.bits | Self::DISABLE_UNCLES.bits |
Self::DISABLE_TWO_PHASE_COMMIT.bits | Self::DISABLE_DAOHEADER.bits |
Self::DISABLE_REWARD.bits |
Self::DISABLE_NON_CONTEXTUAL.bits | Self::DISABLE_SCRIPT.bits;
const ONLY_SCRIPT = Self::DISABLE_ALL.bits & (!Self::DISABLE_SCRIPT.bits);
}
}
impl Switch {
pub fn disable_all(self) -> bool {
self.contains(Switch::DISABLE_ALL)
}
pub fn disable_non_contextual(self) -> bool {
self.contains(Switch::DISABLE_NON_CONTEXTUAL)
}
pub fn disable_epoch(&self) -> bool {
self.contains(Switch::DISABLE_EPOCH)
}
pub fn disable_uncles(&self) -> bool {
self.contains(Switch::DISABLE_UNCLES)
}
pub fn disable_two_phase_commit(&self) -> bool {
self.contains(Switch::DISABLE_TWO_PHASE_COMMIT)
}
pub fn disable_daoheader(&self) -> bool {
self.contains(Switch::DISABLE_DAOHEADER)
}
pub fn disable_reward(&self) -> bool {
self.contains(Switch::DISABLE_REWARD)
}
pub fn disable_script(&self) -> bool {
self.contains(Switch::DISABLE_SCRIPT)
}
}