mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-19 09:50:32 +01:00
Services: migrate to byte[] serialize()
from ByteBuffer buffer()
This commit is contained in:
parent
5ded7782be
commit
98d86375ae
@ -189,7 +189,7 @@ public class PeerAddress extends Message {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
} else {
|
||||
stream.write(services.buffer().array());
|
||||
stream.write(services.serialize());
|
||||
if (addr != null) {
|
||||
// Java does not provide any utility to map an IPv4 address into IPv6 space, so we have to do it by
|
||||
// hand.
|
||||
|
@ -136,15 +136,12 @@ public class Services {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a buffer and writes the node service bits into it. The buffer is backed by a byte array and it's
|
||||
* already rewound for reading.
|
||||
* Allocates a byte array and writes the node service bits into it.
|
||||
*
|
||||
* @return buffer containing the service bits
|
||||
* @return byte array containing the service bits
|
||||
*/
|
||||
public ByteBuffer buffer() {
|
||||
ByteBuffer buf = write(ByteBuffer.allocate(BYTES));
|
||||
((Buffer) buf).rewind();
|
||||
return buf;
|
||||
public byte[] serialize() {
|
||||
return write(ByteBuffer.allocate(BYTES)).array();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -171,7 +171,7 @@ public class VersionMessage extends Message {
|
||||
@Override
|
||||
public void bitcoinSerializeToStream(OutputStream buf) throws IOException {
|
||||
ByteUtils.writeInt32LE(clientVersion, buf);
|
||||
buf.write(localServices.buffer().array());
|
||||
buf.write(localServices.serialize());
|
||||
ByteUtils.writeInt64LE(time.getEpochSecond(), buf);
|
||||
receivingAddr.bitcoinSerializeToStream(buf);
|
||||
fromAddr.bitcoinSerializeToStream(buf);
|
||||
|
Loading…
Reference in New Issue
Block a user