txscript: Optimize typeOfScript pay-to-script-hash.
This begins the process of converting the typeOfScript function to use a combination of raw script analysis and the new tokenizer instead of the far less efficient parsed opcodes with the intent of significantly optimizing the function. In order to ease the review process, each script type will be converted in a separate commit and the typeOfScript function will be updated such that the script is only parsed as a fallback for the cases that are not already converted to more efficient raw script variants. In particular, for this commit, since the ability to detect pay-to-script-hash via raw script analysis is now available, the function is simply updated to make use of it.
This commit is contained in:
parent
9b06388f76
commit
3b86e0a0e2
1 changed files with 5 additions and 2 deletions
|
@ -506,6 +506,11 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass {
|
||||||
return NonStandardTy
|
return NonStandardTy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case isScriptHashScript(script):
|
||||||
|
return ScriptHashTy
|
||||||
|
}
|
||||||
|
|
||||||
pops, err := parseScript(script)
|
pops, err := parseScript(script)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return NonStandardTy
|
return NonStandardTy
|
||||||
|
@ -517,8 +522,6 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass {
|
||||||
return PubKeyHashTy
|
return PubKeyHashTy
|
||||||
} else if isWitnessPubKeyHash(pops) {
|
} else if isWitnessPubKeyHash(pops) {
|
||||||
return WitnessV0PubKeyHashTy
|
return WitnessV0PubKeyHashTy
|
||||||
} else if isScriptHash(pops) {
|
|
||||||
return ScriptHashTy
|
|
||||||
} else if isWitnessScriptHash(pops) {
|
} else if isWitnessScriptHash(pops) {
|
||||||
return WitnessV0ScriptHashTy
|
return WitnessV0ScriptHashTy
|
||||||
} else if isMultiSig(pops) {
|
} else if isMultiSig(pops) {
|
||||||
|
|
Loading…
Reference in a new issue