Skip to content

Commit 3ce5ccc

Browse files
committed
Refactor has_verify_form -> has_free_verify
1 parent aac0178 commit 3ce5ccc

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

src/miniscript/astelem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ impl<Pk: MiniscriptKey + ToPublicKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
710710
Terminal::Check(ref sub) => sub.node.script_size() + 1,
711711
Terminal::DupIf(ref sub) => sub.node.script_size() + 3,
712712
Terminal::Verify(ref sub) => {
713-
sub.node.script_size() + if sub.ext.has_verify_form { 0 } else { 1 }
713+
sub.node.script_size() + if sub.ext.has_free_verify { 0 } else { 1 }
714714
}
715715
Terminal::NonZero(ref sub) => sub.node.script_size() + 4,
716716
Terminal::ZeroNotEqual(ref sub) => sub.node.script_size() + 1,

src/miniscript/types/extra_props.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub struct ExtData {
1818
/// The number of bytes needed to encode its scriptpubkey
1919
pub pk_cost: usize,
2020
/// Whether this fragment can be verify-wrapped for free
21-
pub has_verify_form: bool,
21+
pub has_free_verify: bool,
2222
/// The worst case static(unexecuted) ops-count for this Miniscript fragment.
2323
pub ops_count_static: usize,
2424
/// The worst case ops-count for satisfying this Miniscript fragment.
@@ -35,7 +35,7 @@ impl Property for ExtData {
3535
fn from_true() -> Self {
3636
ExtData {
3737
pk_cost: 1,
38-
has_verify_form: false,
38+
has_free_verify: false,
3939
ops_count_static: 0,
4040
ops_count_sat: Some(0),
4141
ops_count_nsat: None,
@@ -45,7 +45,7 @@ impl Property for ExtData {
4545
fn from_false() -> Self {
4646
ExtData {
4747
pk_cost: 1,
48-
has_verify_form: false,
48+
has_free_verify: false,
4949
ops_count_static: 0,
5050
ops_count_sat: None,
5151
ops_count_nsat: Some(0),
@@ -55,7 +55,7 @@ impl Property for ExtData {
5555
fn from_pk_k() -> Self {
5656
ExtData {
5757
pk_cost: 34,
58-
has_verify_form: false,
58+
has_free_verify: false,
5959
ops_count_static: 0,
6060
ops_count_sat: Some(0),
6161
ops_count_nsat: Some(0),
@@ -65,7 +65,7 @@ impl Property for ExtData {
6565
fn from_pk_h() -> Self {
6666
ExtData {
6767
pk_cost: 24,
68-
has_verify_form: false,
68+
has_free_verify: false,
6969
ops_count_static: 3,
7070
ops_count_sat: Some(3),
7171
ops_count_nsat: Some(3),
@@ -81,7 +81,7 @@ impl Property for ExtData {
8181
};
8282
ExtData {
8383
pk_cost: num_cost + 34 * n + 1,
84-
has_verify_form: true,
84+
has_free_verify: true,
8585
ops_count_static: 1,
8686
ops_count_sat: Some(n + 1),
8787
ops_count_nsat: Some(n + 1),
@@ -96,7 +96,7 @@ impl Property for ExtData {
9696
fn from_sha256() -> Self {
9797
ExtData {
9898
pk_cost: 33 + 6,
99-
has_verify_form: true,
99+
has_free_verify: true,
100100
ops_count_static: 4,
101101
ops_count_sat: Some(4),
102102
ops_count_nsat: None,
@@ -106,7 +106,7 @@ impl Property for ExtData {
106106
fn from_hash256() -> Self {
107107
ExtData {
108108
pk_cost: 33 + 6,
109-
has_verify_form: true,
109+
has_free_verify: true,
110110
ops_count_static: 4,
111111
ops_count_sat: Some(4),
112112
ops_count_nsat: None,
@@ -116,7 +116,7 @@ impl Property for ExtData {
116116
fn from_ripemd160() -> Self {
117117
ExtData {
118118
pk_cost: 21 + 6,
119-
has_verify_form: true,
119+
has_free_verify: true,
120120
ops_count_static: 4,
121121
ops_count_sat: Some(4),
122122
ops_count_nsat: None,
@@ -126,7 +126,7 @@ impl Property for ExtData {
126126
fn from_hash160() -> Self {
127127
ExtData {
128128
pk_cost: 21 + 6,
129-
has_verify_form: true,
129+
has_free_verify: true,
130130
ops_count_static: 4,
131131
ops_count_sat: Some(4),
132132
ops_count_nsat: None,
@@ -136,7 +136,7 @@ impl Property for ExtData {
136136
fn from_time(t: u32) -> Self {
137137
ExtData {
138138
pk_cost: script_num_size(t as usize) + 1,
139-
has_verify_form: false,
139+
has_free_verify: false,
140140
ops_count_static: 1,
141141
ops_count_sat: Some(1),
142142
ops_count_nsat: None,
@@ -145,7 +145,7 @@ impl Property for ExtData {
145145
fn cast_alt(self) -> Result<Self, ErrorKind> {
146146
Ok(ExtData {
147147
pk_cost: self.pk_cost + 2,
148-
has_verify_form: false,
148+
has_free_verify: false,
149149
ops_count_static: self.ops_count_static + 2,
150150
ops_count_sat: self.ops_count_sat.map(|x| x + 2),
151151
ops_count_nsat: self.ops_count_nsat.map(|x| x + 2),
@@ -155,7 +155,7 @@ impl Property for ExtData {
155155
fn cast_swap(self) -> Result<Self, ErrorKind> {
156156
Ok(ExtData {
157157
pk_cost: self.pk_cost + 1,
158-
has_verify_form: self.has_verify_form,
158+
has_free_verify: self.has_free_verify,
159159
ops_count_static: self.ops_count_static + 1,
160160
ops_count_sat: self.ops_count_sat.map(|x| x + 1),
161161
ops_count_nsat: self.ops_count_nsat.map(|x| x + 1),
@@ -165,7 +165,7 @@ impl Property for ExtData {
165165
fn cast_check(self) -> Result<Self, ErrorKind> {
166166
Ok(ExtData {
167167
pk_cost: self.pk_cost + 1,
168-
has_verify_form: true,
168+
has_free_verify: true,
169169
ops_count_static: self.ops_count_static + 1,
170170
ops_count_sat: self.ops_count_sat.map(|x| x + 1),
171171
ops_count_nsat: self.ops_count_nsat.map(|x| x + 1),
@@ -175,18 +175,18 @@ impl Property for ExtData {
175175
fn cast_dupif(self) -> Result<Self, ErrorKind> {
176176
Ok(ExtData {
177177
pk_cost: self.pk_cost + 3,
178-
has_verify_form: false,
178+
has_free_verify: false,
179179
ops_count_static: self.ops_count_static + 3,
180180
ops_count_sat: self.ops_count_sat.map(|x| x + 3),
181181
ops_count_nsat: Some(self.ops_count_static + 3),
182182
})
183183
}
184184

185185
fn cast_verify(self) -> Result<Self, ErrorKind> {
186-
let verify_cost = if self.has_verify_form { 0 } else { 1 };
186+
let verify_cost = if self.has_free_verify { 0 } else { 1 };
187187
Ok(ExtData {
188-
pk_cost: self.pk_cost + if self.has_verify_form { 0 } else { 1 },
189-
has_verify_form: false,
188+
pk_cost: self.pk_cost + if self.has_free_verify { 0 } else { 1 },
189+
has_free_verify: false,
190190
ops_count_static: self.ops_count_static + verify_cost,
191191
ops_count_sat: self.ops_count_sat.map(|x| x + verify_cost),
192192
ops_count_nsat: None,
@@ -196,7 +196,7 @@ impl Property for ExtData {
196196
fn cast_nonzero(self) -> Result<Self, ErrorKind> {
197197
Ok(ExtData {
198198
pk_cost: self.pk_cost + 4,
199-
has_verify_form: false,
199+
has_free_verify: false,
200200
ops_count_static: self.ops_count_static + 4,
201201
ops_count_sat: self.ops_count_sat.map(|x| x + 4),
202202
ops_count_nsat: Some(self.ops_count_static + 4),
@@ -206,7 +206,7 @@ impl Property for ExtData {
206206
fn cast_zeronotequal(self) -> Result<Self, ErrorKind> {
207207
Ok(ExtData {
208208
pk_cost: self.pk_cost + 1,
209-
has_verify_form: false,
209+
has_free_verify: false,
210210
ops_count_static: self.ops_count_static + 1,
211211
ops_count_sat: self.ops_count_sat.map(|x| x + 1),
212212
ops_count_nsat: self.ops_count_nsat.map(|x| x + 1),
@@ -216,7 +216,7 @@ impl Property for ExtData {
216216
fn cast_true(self) -> Result<Self, ErrorKind> {
217217
Ok(ExtData {
218218
pk_cost: self.pk_cost + 1,
219-
has_verify_form: false,
219+
has_free_verify: false,
220220
ops_count_static: self.ops_count_static,
221221
ops_count_sat: self.ops_count_sat,
222222
ops_count_nsat: None,
@@ -231,7 +231,7 @@ impl Property for ExtData {
231231
fn cast_unlikely(self) -> Result<Self, ErrorKind> {
232232
Ok(ExtData {
233233
pk_cost: self.pk_cost + 4,
234-
has_verify_form: false,
234+
has_free_verify: false,
235235
ops_count_static: self.ops_count_static + 3,
236236
ops_count_sat: self.ops_count_sat.map(|x| x + 3),
237237
ops_count_nsat: Some(self.ops_count_static + 3),
@@ -241,7 +241,7 @@ impl Property for ExtData {
241241
fn cast_likely(self) -> Result<Self, ErrorKind> {
242242
Ok(ExtData {
243243
pk_cost: self.pk_cost + 4,
244-
has_verify_form: false,
244+
has_free_verify: false,
245245
ops_count_static: self.ops_count_static + 3,
246246
ops_count_sat: self.ops_count_sat.map(|x| x + 3),
247247
ops_count_nsat: Some(self.ops_count_static + 3),
@@ -251,7 +251,7 @@ impl Property for ExtData {
251251
fn and_b(l: Self, r: Self) -> Result<Self, ErrorKind> {
252252
Ok(ExtData {
253253
pk_cost: l.pk_cost + r.pk_cost + 1,
254-
has_verify_form: false,
254+
has_free_verify: false,
255255
ops_count_static: l.ops_count_static + r.ops_count_static + 1,
256256
ops_count_sat: l
257257
.ops_count_sat
@@ -265,7 +265,7 @@ impl Property for ExtData {
265265
fn and_v(l: Self, r: Self) -> Result<Self, ErrorKind> {
266266
Ok(ExtData {
267267
pk_cost: l.pk_cost + r.pk_cost,
268-
has_verify_form: r.has_verify_form,
268+
has_free_verify: r.has_free_verify,
269269
ops_count_static: l.ops_count_static + r.ops_count_static,
270270
ops_count_sat: l.ops_count_sat.and_then(|x| r.ops_count_sat.map(|y| x + y)),
271271
ops_count_nsat: None,
@@ -275,7 +275,7 @@ impl Property for ExtData {
275275
fn or_b(l: Self, r: Self) -> Result<Self, ErrorKind> {
276276
Ok(ExtData {
277277
pk_cost: l.pk_cost + r.pk_cost + 1,
278-
has_verify_form: false,
278+
has_free_verify: false,
279279
ops_count_static: l.ops_count_static + r.ops_count_static + 1,
280280
ops_count_sat: cmp::max(
281281
l.ops_count_sat
@@ -292,7 +292,7 @@ impl Property for ExtData {
292292
fn or_d(l: Self, r: Self) -> Result<Self, ErrorKind> {
293293
Ok(ExtData {
294294
pk_cost: l.pk_cost + r.pk_cost + 3,
295-
has_verify_form: false,
295+
has_free_verify: false,
296296
ops_count_static: l.ops_count_static + r.ops_count_static + 1,
297297
ops_count_sat: cmp::max(
298298
l.ops_count_sat.map(|x| x + 3 + r.ops_count_static),
@@ -308,7 +308,7 @@ impl Property for ExtData {
308308
fn or_c(l: Self, r: Self) -> Result<Self, ErrorKind> {
309309
Ok(ExtData {
310310
pk_cost: l.pk_cost + r.pk_cost + 2,
311-
has_verify_form: false,
311+
has_free_verify: false,
312312
ops_count_static: l.ops_count_static + r.ops_count_static + 2,
313313
ops_count_sat: cmp::max(
314314
l.ops_count_sat.map(|x| x + 2 + r.ops_count_static),
@@ -322,7 +322,7 @@ impl Property for ExtData {
322322
fn or_i(l: Self, r: Self) -> Result<Self, ErrorKind> {
323323
Ok(ExtData {
324324
pk_cost: l.pk_cost + r.pk_cost + 3,
325-
has_verify_form: false,
325+
has_free_verify: false,
326326
ops_count_static: l.ops_count_static + r.ops_count_static + 3,
327327
ops_count_sat: cmp::max(
328328
l.ops_count_sat.map(|x| x + 3 + r.ops_count_static),
@@ -339,7 +339,7 @@ impl Property for ExtData {
339339
fn and_or(a: Self, b: Self, c: Self) -> Result<Self, ErrorKind> {
340340
Ok(ExtData {
341341
pk_cost: a.pk_cost + b.pk_cost + c.pk_cost + 3,
342-
has_verify_form: false,
342+
has_free_verify: false,
343343
ops_count_static: a.ops_count_static + b.ops_count_static + c.ops_count_static + 3,
344344
ops_count_sat: cmp::max(
345345
a.ops_count_sat
@@ -397,7 +397,7 @@ impl Property for ExtData {
397397
}
398398
Ok(ExtData {
399399
pk_cost: pk_cost + n - 1, //all pk cost + (n-1)*ADD
400-
has_verify_form: true,
400+
has_free_verify: true,
401401
ops_count_static: ops_count_static + (n - 1) + 1, //adds and equal
402402
ops_count_sat: ops_count_sat
403403
.map(|x: usize| (x + (n - 1) + 1 + (sum + ops_count_nsat_sum as i32) as usize)), //adds and equal

src/policy/compiler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct CompilationKey {
113113
ty: Type,
114114

115115
/// Whether that result cannot be easily converted into verify form.
116-
/// This is exactly the opposite of has_verify_form in the data-types.
116+
/// This is exactly the opposite of has_free_verify in the data-types.
117117
/// This is required in cases where it is important to distinguish between
118118
/// two Compilation of the same-type: one of which is expensive to verify
119119
/// and the other is not.
@@ -662,7 +662,7 @@ fn insert_elem<Pk: MiniscriptKey, Ctx: ScriptContext>(
662662

663663
let elem_cost = elem.cost_1d(sat_prob, dissat_prob);
664664

665-
let elem_key = CompilationKey::from_type(elem.ms.ty, elem.ms.ext.has_verify_form, dissat_prob);
665+
let elem_key = CompilationKey::from_type(elem.ms.ty, elem.ms.ext.has_free_verify, dissat_prob);
666666

667667
// Check whether the new element is worse than any existing element. If there
668668
// is an element which is a subtype of the current element and has better
@@ -838,7 +838,7 @@ where
838838
zero_comp.insert(
839839
CompilationKey::from_type(
840840
Type::from_false(),
841-
ExtData::from_false().has_verify_form,
841+
ExtData::from_false().has_free_verify,
842842
dissat_prob,
843843
),
844844
AstElemExt::terminal(Terminal::False),

0 commit comments

Comments
 (0)