txscript: reduce allocs in calcSignatureHash

This commit is contained in:
David Hill 2016-11-16 10:43:17 -05:00 committed by Dave Collins
parent 187355448a
commit b134beb3b7

View File

@ -355,9 +355,9 @@ func calcSignatureHash(script []parsedOpcode, hashType SigHashType, tx *wire.Msg
// The final hash is the double sha256 of both the serialized modified
// transaction and the hash type (encoded as a 4-byte little-endian
// value) appended.
var wbuf bytes.Buffer
txCopy.Serialize(&wbuf)
binary.Write(&wbuf, binary.LittleEndian, hashType)
wbuf := bytes.NewBuffer(make([]byte, 0, txCopy.SerializeSize()+4))
txCopy.Serialize(wbuf)
binary.Write(wbuf, binary.LittleEndian, hashType)
return chainhash.DoubleHashB(wbuf.Bytes())
}