From fbcc23fa143ba2b00e131bced2fde206051e17dc Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Tue, 27 Sep 2016 15:41:46 +1000 Subject: [PATCH] TransactionBuilder: avoid unnecessary cache object --- src/transaction_builder.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/transaction_builder.js b/src/transaction_builder.js index 37f7b6f..c635754 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -16,7 +16,7 @@ var Transaction = require('./transaction') function fixMSSignatures (transaction, vin, pubKeys, signatures, prevOutScript, hashType, skipPubKey) { // maintain a local copy of unmatched signatures var unmatched = signatures.slice() - var cache = {} + var signatureHash return pubKeys.map(function (pubKey) { // skip optionally provided pubKey @@ -30,7 +30,9 @@ function fixMSSignatures (transaction, vin, pubKeys, signatures, prevOutScript, // skip if undefined || OP_0 if (!signature) return false - var signatureHash = cache[hashType] = cache[hashType] || transaction.hashForSignature(vin, prevOutScript, hashType) + if (!signatureHash) { + signatureHash = transaction.hashForSignature(vin, prevOutScript, hashType) + } if (!keyPair2.verify(signatureHash, signature)) return false // remove matched signature from unmatched