Skip to content

Commit

Permalink
txscript: Optimize GetWitnessSigOpCount
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cfromknecht committed Feb 5, 2021
1 parent 931aab2 commit f3185ee
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions txscript/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,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)
}
}

Expand Down

0 comments on commit f3185ee

Please sign in to comment.