Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
txscript: Optimize IsPushOnlyScript.
This converts the IsPushOnlyScript function to make use of the new tokenizer instead of the far less efficient parseScript thereby significantly optimizing the function. It also deprecates the isPushOnly function that requires opcodes in favor of the new function and modifies the comment on IsPushOnlyScript to explicitly call out the script version semantics. The following is a before and after comparison of analyzing a large script: benchmark old ns/op new ns/op delta --------------------------------------------------------------- BenchmarkIsPayToScriptHash 139961 0.66 -100.00% benchmark old allocs new allocs delta --------------------------------------------------------------- BenchmarkIsPayToScriptHash 1 0 -100.00% benchmark old bytes new bytes delta --------------------------------------------------------------- BenchmarkIsPayToScriptHash 466944 0 -100.00%
- Loading branch information