mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 18:00:11 +01:00
Add benchmarks for writeTxOut.
This commit adds a benchmark for the writeTxOut function.
This commit is contained in:
parent
48c350f379
commit
ab8c8e2d39
@ -140,3 +140,12 @@ func BenchmarkWriteOutPoint(b *testing.B) {
|
||||
btcwire.TstWriteOutPoint(ioutil.Discard, 0, 0, op)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkWriteTxOut performs a benchmark on how long it takes to write
|
||||
// a transaction output.
|
||||
func BenchmarkWriteTxOut(b *testing.B) {
|
||||
txOut := blockOne.Transactions[0].TxOut[0]
|
||||
for i := 0; i < b.N; i++ {
|
||||
btcwire.TstWriteTxOut(ioutil.Discard, 0, 0, txOut)
|
||||
}
|
||||
}
|
||||
|
@ -114,3 +114,9 @@ func TstReadOutPoint(r io.Reader, pver uint32, version uint32, op *OutPoint) err
|
||||
func TstWriteOutPoint(w io.Writer, pver uint32, version uint32, op *OutPoint) error {
|
||||
return writeOutPoint(w, pver, version, op)
|
||||
}
|
||||
|
||||
// TstWriteTxOut makes the internal writeTxOut function available to the test
|
||||
// package.
|
||||
func TstWriteTxOut(w io.Writer, pver uint32, version uint32, to *TxOut) error {
|
||||
return writeTxOut(w, pver, version, to)
|
||||
}
|
||||
|
4
msgtx.go
4
msgtx.go
@ -339,7 +339,7 @@ func (msg *MsgTx) BtcEncode(w io.Writer, pver uint32) error {
|
||||
}
|
||||
|
||||
for _, to := range msg.TxOut {
|
||||
err = writeTxOut(w, pver, to)
|
||||
err = writeTxOut(w, pver, msg.Version, to)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -551,7 +551,7 @@ func readTxOut(r io.Reader, pver uint32, version uint32, to *TxOut) error {
|
||||
|
||||
// writeTxOut encodes to into the bitcoin protocol encoding for a transaction
|
||||
// output (TxOut) to w.
|
||||
func writeTxOut(w io.Writer, pver uint32, to *TxOut) error {
|
||||
func writeTxOut(w io.Writer, pver uint32, version uint32, to *TxOut) error {
|
||||
err := writeElement(w, to.Value)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user