Skip to content

Commit 0c8d12d

Browse files
committed
Merge #378: Refactor opcode calculations
ae0ce13 Simplify algorithm for opcode counting (sanket1729) 239efd5 Fill in default definitions (sanket1729) Pull request description: - Instead of explicitly counting all opcodes required while satisfaction, we explicitly track only additional opcodes while satisfaction and dissatisfaction. - Removes some unnecessary code around wrapper casting Double-checked and compared with the c++ codebase ACKs for top commit: apoelstra: ACK ae0ce13 Tree-SHA512: 54f9c0bdd386645b595dc2de27513db15f2377525d7f9ad7899f07d3b434b0e40d9b24db8e87c2411c4d670ad17143f1ef50e490531f08395c136fa0897b986c
2 parents 8ebb556 + ae0ce13 commit 0c8d12d

File tree

5 files changed

+125
-213
lines changed

5 files changed

+125
-213
lines changed

src/miniscript/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl ScriptContext for Legacy {
381381
fn check_local_consensus_validity<Pk: MiniscriptKey>(
382382
ms: &Miniscript<Pk, Self>,
383383
) -> Result<(), ScriptContextError> {
384-
match ms.ext.ops_count_sat {
384+
match ms.ext.ops.op_count() {
385385
None => Err(ScriptContextError::MaxOpCountExceeded),
386386
Some(op_count) if op_count > MAX_OPS_PER_SCRIPT => {
387387
Err(ScriptContextError::MaxOpCountExceeded)
@@ -494,7 +494,7 @@ impl ScriptContext for Segwitv0 {
494494
fn check_local_consensus_validity<Pk: MiniscriptKey>(
495495
ms: &Miniscript<Pk, Self>,
496496
) -> Result<(), ScriptContextError> {
497-
match ms.ext.ops_count_sat {
497+
match ms.ext.ops.op_count() {
498498
None => Err(ScriptContextError::MaxOpCountExceeded),
499499
Some(op_count) if op_count > MAX_OPS_PER_SCRIPT => {
500500
Err(ScriptContextError::MaxOpCountExceeded)
@@ -711,7 +711,7 @@ impl ScriptContext for BareCtx {
711711
fn check_local_consensus_validity<Pk: MiniscriptKey>(
712712
ms: &Miniscript<Pk, Self>,
713713
) -> Result<(), ScriptContextError> {
714-
match ms.ext.ops_count_sat {
714+
match ms.ext.ops.op_count() {
715715
None => Err(ScriptContextError::MaxOpCountExceeded),
716716
Some(op_count) if op_count > MAX_OPS_PER_SCRIPT => {
717717
Err(ScriptContextError::MaxOpCountExceeded)

src/miniscript/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ mod tests {
584584
assert_eq!(format!("{:x}", ms.encode()), expected_hex);
585585
assert_eq!(ms.ty.mall.non_malleable, non_mal);
586586
assert_eq!(ms.ty.mall.safe, need_sig);
587-
assert_eq!(ms.ext.ops_count_sat.unwrap(), ops);
587+
assert_eq!(ms.ext.ops.op_count().unwrap(), ops);
588588
}
589589
(Err(_), false) => return,
590590
_ => unreachable!(),

0 commit comments

Comments
 (0)