Skip to content

Commit

Permalink
Merge #643: call reduce0 from reduce1 and 2
Browse files Browse the repository at this point in the history
5c48516 call reduce0 from reduce1 and 2 (Riccardo Casatta)

Pull request description:

  reduce code duplication by calling the function that provide the same check and side effects

ACKs for top commit:
  apoelstra:
    ACK 5c48516 neat!

Tree-SHA512: 7e37af561737e48dbe0d86d3bb86adc28d3a098155d6eb35f7686f7ff97597449de0b6356a9bae4dda943fb19f3cd9ff4f1b1bbca25cafc15f2b0eecb4dd27b3
  • Loading branch information
apoelstra committed Feb 26, 2024
2 parents 18b1b30 + 5c48516 commit 666918f
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/miniscript/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> TerminalStack<Pk, Ctx> {
let top = self.pop().unwrap();
let wrapped_ms = wrap(Arc::new(top));

let ty = Type::type_check(&wrapped_ms)?;
let ext = ExtData::type_check(&wrapped_ms)?;
let ms = Miniscript { node: wrapped_ms, ty, ext, phantom: PhantomData };
Ctx::check_global_validity(&ms)?;
self.0.push(ms);
Ok(())
self.reduce0(wrapped_ms)
}

///reduce, type check and push a 2-arg node
Expand All @@ -246,12 +241,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> TerminalStack<Pk, Ctx> {

let wrapped_ms = wrap(Arc::new(left), Arc::new(right));

let ty = Type::type_check(&wrapped_ms)?;
let ext = ExtData::type_check(&wrapped_ms)?;
let ms = Miniscript { node: wrapped_ms, ty, ext, phantom: PhantomData };
Ctx::check_global_validity(&ms)?;
self.0.push(ms);
Ok(())
self.reduce0(wrapped_ms)
}
}

Expand Down

0 comments on commit 666918f

Please sign in to comment.