txscript: Optimize ExtractPkScriptAddr assume non-standard if no success
This completes the process of converting the ExtractPkScriptAddr function to use the optimized extraction functions recently introduced as part of the typeOfScript conversion. In particular, this cleans up the final remaining case for non-standard transactions. The method now returns NonStandardTy direclty if no other branch was taken. The following is a before and after comparison of attempting to extract pkscript addrs from a very large, non-standard script. benchmark old ns/op new ns/op delta BenchmarkExtractPkScriptAddrsLarge-8 60713 17.0 -99.97% BenchmarkExtractPkScriptAddrs-8 289 17.0 -94.12% benchmark old allocs new allocs delta BenchmarkExtractPkScriptAddrsLarge-8 1 0 -100.00% BenchmarkExtractPkScriptAddrs-8 1 0 -100.00% benchmark old bytes new bytes delta BenchmarkExtractPkScriptAddrsLarge-8 311299 0 -100.00% BenchmarkExtractPkScriptAddrs-8 768 0 -100.00%
This commit is contained in:
parent
37f9cdd115
commit
67168099d3
1 changed files with 2 additions and 17 deletions
|
@ -908,23 +908,8 @@ func ExtractPkScriptAddrs(pkScript []byte, chainParams *chaincfg.Params) (Script
|
|||
return WitnessV0ScriptHashTy, addrs, 1, nil
|
||||
}
|
||||
|
||||
// Fall back to slow path. Ultimately these are intended to be replaced by
|
||||
// faster variants based on the unparsed raw scripts.
|
||||
|
||||
var addrs []btcutil.Address
|
||||
var requiredSigs int
|
||||
|
||||
scriptClass := typeOfScript(scriptVersion, pkScript)
|
||||
|
||||
switch scriptClass {
|
||||
case NonStandardTy:
|
||||
// Don't attempt to extract addresses or required signatures for
|
||||
// nonstandard transactions.
|
||||
}
|
||||
|
||||
// Don't attempt to extract addresses or required signatures for nonstandard
|
||||
// transactions.
|
||||
return scriptClass, addrs, requiredSigs, nil
|
||||
// If none of the above passed, then the address must be non-standard.
|
||||
return NonStandardTy, nil, 0, nil
|
||||
}
|
||||
|
||||
// AtomicSwapDataPushes houses the data pushes found in atomic swap contracts.
|
||||
|
|
Loading…
Reference in a new issue