Skip to content

Commit 5f0072c

Browse files
committed
typeck: move opcode limits into sat/dissat limits
This consolidates two Option fields into existing Option fields, unifying a bunch of code. It also deletes some crufty utility functions. This one actually has pretty good tests.
1 parent f57cac0 commit 5f0072c

File tree

4 files changed

+91
-120
lines changed

4 files changed

+91
-120
lines changed

src/miniscript/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ impl ScriptContext for Legacy {
436436
fn check_local_consensus_validity<Pk: MiniscriptKey>(
437437
ms: &Miniscript<Pk, Self>,
438438
) -> Result<(), ScriptContextError> {
439-
match ms.ext.ops.op_count() {
439+
match ms.ext.sat_op_count() {
440440
None => Err(ScriptContextError::ImpossibleSatisfaction),
441441
Some(op_count) if op_count > MAX_OPS_PER_SCRIPT => {
442442
Err(ScriptContextError::MaxOpCountExceeded {
@@ -550,7 +550,7 @@ impl ScriptContext for Segwitv0 {
550550
fn check_local_consensus_validity<Pk: MiniscriptKey>(
551551
ms: &Miniscript<Pk, Self>,
552552
) -> Result<(), ScriptContextError> {
553-
match ms.ext.ops.op_count() {
553+
match ms.ext.sat_op_count() {
554554
None => Err(ScriptContextError::ImpossibleSatisfaction),
555555
Some(op_count) if op_count > MAX_OPS_PER_SCRIPT => {
556556
Err(ScriptContextError::MaxOpCountExceeded {
@@ -783,7 +783,7 @@ impl ScriptContext for BareCtx {
783783
fn check_local_consensus_validity<Pk: MiniscriptKey>(
784784
ms: &Miniscript<Pk, Self>,
785785
) -> Result<(), ScriptContextError> {
786-
match ms.ext.ops.op_count() {
786+
match ms.ext.sat_op_count() {
787787
None => Err(ScriptContextError::ImpossibleSatisfaction),
788788
Some(op_count) if op_count > MAX_OPS_PER_SCRIPT => {
789789
Err(ScriptContextError::MaxOpCountExceeded {

src/miniscript/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ mod tests {
11931193
assert_eq!(format!("{:x}", ms.encode()), expected_hex);
11941194
assert_eq!(ms.ty.mall.non_malleable, non_mal);
11951195
assert_eq!(ms.ty.mall.safe, need_sig);
1196-
assert_eq!(ms.ext.ops.op_count().unwrap(), ops);
1196+
assert_eq!(ms.ext.static_ops + ms.ext.sat_data.unwrap().max_exec_op_count, ops);
11971197
}
11981198
(Err(_), false) => {}
11991199
_ => unreachable!(),

0 commit comments

Comments
 (0)