From 77863f5649cbd55e58e2c3ebdd8587de9edcaef7 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 4 Feb 2021 14:14:53 -0800 Subject: [PATCH] txscript: Optimize GetWitnessSigOpCount This converts the GetWitnessSigOpCount function to use a combination of raw script analysis and the new tokenizer instead of the far less efficeint parseScript, thereby significantly optimizing the funciton. In particular, it use the recently added countSigOpsv0 in precise mode to avoid calling paseScript. --- txscript/script.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/txscript/script.go b/txscript/script.go index aee1aaac..b69c915a 100644 --- a/txscript/script.go +++ b/txscript/script.go @@ -955,8 +955,7 @@ func getWitnessSigOps(pkScript []byte, witness wire.TxWitness) int { len(witness) > 0: witnessScript := witness[len(witness)-1] - pops, _ := parseScript(witnessScript) - return getSigOpCount(pops, true) + return countSigOpsV0(witnessScript, true) } }