mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 18:00:11 +01:00
Optimize writeTxIn.
Before: BenchmarkWriteTxIn 5000000 422 ns/op After: BenchmarkWriteTxIn 5000000 389 ns/op This is part of the ongoing effort to optimize serialization as noted in conformal/btcd#27.
This commit is contained in:
parent
63cc0851e5
commit
1a1f93865f
7
msgtx.go
7
msgtx.go
@ -504,13 +504,14 @@ func writeTxIn(w io.Writer, pver uint32, version uint32, ti *TxIn) error {
|
||||
return err
|
||||
}
|
||||
|
||||
b := []byte(ti.SignatureScript)
|
||||
_, err = w.Write(b)
|
||||
_, err = w.Write(ti.SignatureScript)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = writeElement(w, &ti.Sequence)
|
||||
buf := make([]byte, 4)
|
||||
binary.LittleEndian.PutUint32(buf, ti.Sequence)
|
||||
_, err = w.Write(buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user