mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-14 03:48:28 +01:00
TransactionInput, TransactionOutPoint: in write(), prefer calling write() over serialize()
The reason is `write()` re-uses the `ByteBuffer`, whereas `serialize()` allocates an intermediate byte array.
This commit is contained in:
parent
a5aaa8924a
commit
f7c7e421fc
2 changed files with 2 additions and 2 deletions
|
@ -170,7 +170,7 @@ public class TransactionInput {
|
|||
* @throws BufferOverflowException if the input doesn't fit the remaining buffer
|
||||
*/
|
||||
public ByteBuffer write(ByteBuffer buf) throws BufferOverflowException {
|
||||
buf.put(outpoint.serialize());
|
||||
outpoint.write(buf);
|
||||
Buffers.writeLengthPrefixedBytes(buf, scriptBytes);
|
||||
ByteUtils.writeInt32LE(sequence, buf);
|
||||
return buf;
|
||||
|
|
|
@ -103,7 +103,7 @@ public class TransactionOutPoint {
|
|||
* @throws BufferOverflowException if the outpoint doesn't fit the remaining buffer
|
||||
*/
|
||||
public ByteBuffer write(ByteBuffer buf) throws BufferOverflowException {
|
||||
buf.put(hash.serialize());
|
||||
hash.write(buf);
|
||||
ByteUtils.writeInt32LE(index, buf);
|
||||
return buf;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue