@@ -42,7 +42,7 @@ pub struct OpLimits {
42
42
43
43
impl OpLimits {
44
44
/// Creates a new instance of [`OpLimits`]
45
- pub fn new ( op_static : usize , op_sat : Option < usize > , op_nsat : Option < usize > ) -> Self {
45
+ pub const fn new ( op_static : usize , op_sat : Option < usize > , op_nsat : Option < usize > ) -> Self {
46
46
OpLimits { count : op_static, sat : op_sat, nsat : op_nsat }
47
47
}
48
48
@@ -51,6 +51,17 @@ impl OpLimits {
51
51
}
52
52
53
53
impl TimelockInfo {
54
+ /// Creates a new `TimelockInfo` with all fields set to false.
55
+ pub const fn new ( ) -> Self {
56
+ TimelockInfo {
57
+ csv_with_height : false ,
58
+ csv_with_time : false ,
59
+ cltv_with_height : false ,
60
+ cltv_with_time : false ,
61
+ contains_combination : false ,
62
+ }
63
+ }
64
+
54
65
/// Returns true if the current `TimelockInfo` contains any possible unspendable paths.
55
66
pub fn contains_unspendable_path ( self ) -> bool { self . contains_combination }
56
67
@@ -133,6 +144,36 @@ pub struct ExtData {
133
144
pub exec_stack_elem_count_dissat : Option < usize > ,
134
145
}
135
146
147
+ impl ExtData {
148
+ /// Extra data for the `0` combinator
149
+ pub const FALSE : Self = ExtData {
150
+ pk_cost : 1 ,
151
+ has_free_verify : false ,
152
+ ops : OpLimits :: new ( 0 , None , Some ( 0 ) ) ,
153
+ stack_elem_count_sat : None ,
154
+ stack_elem_count_dissat : Some ( 0 ) ,
155
+ max_sat_size : None ,
156
+ max_dissat_size : Some ( ( 0 , 0 ) ) ,
157
+ timelock_info : TimelockInfo :: new ( ) ,
158
+ exec_stack_elem_count_sat : None ,
159
+ exec_stack_elem_count_dissat : Some ( 1 ) ,
160
+ } ;
161
+
162
+ /// Extra data for the `1` combinator
163
+ pub const TRUE : Self = ExtData {
164
+ pk_cost : 1 ,
165
+ has_free_verify : false ,
166
+ ops : OpLimits :: new ( 0 , Some ( 0 ) , None ) ,
167
+ stack_elem_count_sat : Some ( 0 ) ,
168
+ stack_elem_count_dissat : None ,
169
+ max_sat_size : Some ( ( 0 , 0 ) ) ,
170
+ max_dissat_size : None ,
171
+ timelock_info : TimelockInfo :: new ( ) ,
172
+ exec_stack_elem_count_sat : Some ( 1 ) ,
173
+ exec_stack_elem_count_dissat : None ,
174
+ } ;
175
+ }
176
+
136
177
impl Property for ExtData {
137
178
fn sanity_checks ( & self ) {
138
179
debug_assert_eq ! (
@@ -145,35 +186,9 @@ impl Property for ExtData {
145
186
) ;
146
187
}
147
188
148
- fn from_true ( ) -> Self {
149
- ExtData {
150
- pk_cost : 1 ,
151
- has_free_verify : false ,
152
- ops : OpLimits :: new ( 0 , Some ( 0 ) , None ) ,
153
- stack_elem_count_sat : Some ( 0 ) ,
154
- stack_elem_count_dissat : None ,
155
- max_sat_size : Some ( ( 0 , 0 ) ) ,
156
- max_dissat_size : None ,
157
- timelock_info : TimelockInfo :: default ( ) ,
158
- exec_stack_elem_count_sat : Some ( 1 ) ,
159
- exec_stack_elem_count_dissat : None ,
160
- }
161
- }
189
+ fn from_true ( ) -> Self { Self :: TRUE }
162
190
163
- fn from_false ( ) -> Self {
164
- ExtData {
165
- pk_cost : 1 ,
166
- has_free_verify : false ,
167
- ops : OpLimits :: new ( 0 , None , Some ( 0 ) ) ,
168
- stack_elem_count_sat : None ,
169
- stack_elem_count_dissat : Some ( 0 ) ,
170
- max_sat_size : None ,
171
- max_dissat_size : Some ( ( 0 , 0 ) ) ,
172
- timelock_info : TimelockInfo :: default ( ) ,
173
- exec_stack_elem_count_sat : None ,
174
- exec_stack_elem_count_dissat : Some ( 1 ) ,
175
- }
176
- }
191
+ fn from_false ( ) -> Self { Self :: FALSE }
177
192
178
193
fn from_pk_k < Ctx : ScriptContext > ( ) -> Self {
179
194
ExtData {
0 commit comments