Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
txscript: Optimize CalcSignatureHash.
This modifies the CalcSignatureHash function to make use of the new signature hash calculation function that accepts raw scripts without needing to first parse them. Consequently, it also doubles as a slight optimization to the execution time and a significant reduction in the number of allocations. In order to convert the CalcScriptHash function and keep the same semantics, a new function named checkScriptParses is introduced which will quickly determine if a script can be fully parsed without failure and return the parse failure in the case it can't. The following is a before and after comparison of analyzing a large multiple input transaction: benchmark old ns/op new ns/op delta ------------------------------------------------------- BenchmarkCalcSigHash 2792057 2760042 -1.15% benchmark old allocs new allocs delta ------------------------------------------------------- BenchmarkCalcSigHash 1691 1068 -36.84% benchmark old bytes new bytes delta ------------------------------------------------------- BenchmarkCalcSigHash 521673 438604 -15.92%
- Loading branch information