Skip to content

Commit

Permalink
txscript: Optimize typeOfScript for null data scripts
Browse files Browse the repository at this point in the history
This continues the process of converting the typeOfScript function to
use a combination of raw script analysize and the tokenizer instead of
parsed opcode, with the intent of significanty optimizing the function.

In particular, it converts the detection of null data scripts to use raw
script analysis.
  • Loading branch information
cfromknecht committed Feb 5, 2021
1 parent bf287f5 commit 612f05c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions txscript/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass {
return ScriptHashTy
case isMultisigScript(scriptVersion, script):
return MultiSigTy
case isNullDataScript(scriptVersion, script):
return NullDataTy
}

pops, err := parseScript(script)
Expand All @@ -461,9 +463,8 @@ func typeOfScript(scriptVersion uint16, script []byte) ScriptClass {
return WitnessV0PubKeyHashTy
} else if isWitnessScriptHash(pops) {
return WitnessV0ScriptHashTy
} else if isNullData(pops) {
return NullDataTy
}

return NonStandardTy
}

Expand Down

0 comments on commit 612f05c

Please sign in to comment.