Skip to content

Commit f1a9238

Browse files
committed
Update multi_a to not include n wrapper
While we are at it, do not use the default impl. This makes these types of error easy to make. I think this could have easily been prevently if I was forced to explicitly write AnyNonZero in front of multi_a
1 parent 65a8ea8 commit f1a9238

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

src/miniscript/types/correctness.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ impl Property for Correctness {
173173
}
174174
}
175175

176+
fn from_multi_a(_: usize, _: usize) -> Self {
177+
Correctness {
178+
base: Base::B,
179+
input: Input::Any,
180+
dissatisfiable: true,
181+
unit: true,
182+
}
183+
}
184+
176185
fn from_hash() -> Self {
177186
Correctness {
178187
base: Base::B,

src/miniscript/types/malleability.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ impl Property for Malleability {
122122
}
123123
}
124124

125+
fn from_multi_a(_: usize, _: usize) -> Self {
126+
Malleability {
127+
dissat: Dissat::Unique,
128+
safe: true,
129+
non_malleable: true,
130+
}
131+
}
132+
125133
fn from_hash() -> Self {
126134
Malleability {
127135
dissat: Dissat::Unknown,

src/miniscript/types/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,7 @@ pub trait Property: Sized {
270270
fn from_multi(k: usize, n: usize) -> Self;
271271

272272
/// Type property of a `MultiA` fragment
273-
fn from_multi_a(k: usize, n: usize) -> Self {
274-
// default impl same as multi
275-
Self::from_multi(k, n)
276-
}
273+
fn from_multi_a(k: usize, n: usize) -> Self;
277274

278275
/// Type property of a hash fragment
279276
fn from_hash() -> Self;
@@ -584,6 +581,13 @@ impl Property for Type {
584581
}
585582
}
586583

584+
fn from_multi_a(k: usize, n: usize) -> Self {
585+
Type {
586+
corr: Property::from_multi_a(k, n),
587+
mall: Property::from_multi_a(k, n),
588+
}
589+
}
590+
587591
fn from_hash() -> Self {
588592
Type {
589593
corr: Property::from_hash(),

src/policy/compiler.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ impl Property for CompilerExtData {
191191
}
192192
}
193193

194+
fn from_multi_a(k: usize, n: usize) -> Self {
195+
CompilerExtData {
196+
branch_prob: None,
197+
sat_cost: 66.0 * k as f64 + (n - k) as f64,
198+
dissat_cost: Some(n as f64), /* <w_n> ... <w_1> := 0x00 ... 0x00 (n times) */
199+
}
200+
}
201+
194202
fn from_hash() -> Self {
195203
CompilerExtData {
196204
branch_prob: None,

0 commit comments

Comments
 (0)