Skip to content

Commit 666918f

Browse files
committedFeb 26, 2024··
Merge #643: call reduce0 from reduce1 and 2
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
2 parents 18b1b30 + 5c48516 commit 666918f

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed
 

‎src/miniscript/decode.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> TerminalStack<Pk, Ctx> {
228228
let top = self.pop().unwrap();
229229
let wrapped_ms = wrap(Arc::new(top));
230230

231-
let ty = Type::type_check(&wrapped_ms)?;
232-
let ext = ExtData::type_check(&wrapped_ms)?;
233-
let ms = Miniscript { node: wrapped_ms, ty, ext, phantom: PhantomData };
234-
Ctx::check_global_validity(&ms)?;
235-
self.0.push(ms);
236-
Ok(())
231+
self.reduce0(wrapped_ms)
237232
}
238233

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

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

249-
let ty = Type::type_check(&wrapped_ms)?;
250-
let ext = ExtData::type_check(&wrapped_ms)?;
251-
let ms = Miniscript { node: wrapped_ms, ty, ext, phantom: PhantomData };
252-
Ctx::check_global_validity(&ms)?;
253-
self.0.push(ms);
254-
Ok(())
244+
self.reduce0(wrapped_ms)
255245
}
256246
}
257247

0 commit comments

Comments
 (0)
Please sign in to comment.