Skip to content

Commit

Permalink
txscript: Refactor to implement tokenizer from drcd
Browse files Browse the repository at this point in the history
parseScriptTemplate will allocate a copy of the script onto memory,
leading to excessive memory allocation. This commit brings the tokenizer
to btcd and modifies it to fit with Bitcoin.
  • Loading branch information
kcalvinalvin committed Feb 2, 2021
1 parent 7bbd9b0 commit d6a1621
Show file tree
Hide file tree
Showing 17 changed files with 2,090 additions and 4,791 deletions.
3 changes: 1 addition & 2 deletions blockchain/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,7 @@ func CountP2SHSigOps(tx *btcutil.Tx, isCoinBaseTx bool, utxoView *UtxoViewpoint)
// Count the precise number of signature operations in the
// referenced public key script.
sigScript := txIn.SignatureScript
numSigOps := txscript.GetPreciseSigOpCount(sigScript, pkScript,
true)
numSigOps := txscript.GetPreciseSigOpCount(sigScript, pkScript)

// We could potentially overflow the accumulator so check for
// overflow.
Expand Down
2 changes: 1 addition & 1 deletion mempool/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func checkInputsStandard(tx *btcutil.Tx, utxoView *blockchain.UtxoViewpoint) err
switch txscript.GetScriptClass(originPkScript) {
case txscript.ScriptHashTy:
numSigOps := txscript.GetPreciseSigOpCount(
txIn.SignatureScript, originPkScript, true)
txIn.SignatureScript, originPkScript)
if numSigOps > maxStandardP2SHSigOps {
str := fmt.Sprintf("transaction input #%d has "+
"%d signature operations which is more "+
Expand Down
Loading

0 comments on commit d6a1621

Please sign in to comment.