mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-19 09:50:32 +01:00
Ping: move parse()
to static constructor read()
This commit is contained in:
parent
7d31021663
commit
1f8ed23e24
@ -240,7 +240,7 @@ public class BitcoinSerializer extends MessageSerializer {
|
||||
} else if (command.equals("addrv2")) {
|
||||
return makeAddressV2Message(payload);
|
||||
} else if (command.equals("ping")) {
|
||||
return new Ping(payload);
|
||||
return Ping.read(payload);
|
||||
} else if (command.equals("pong")) {
|
||||
return new Pong(payload);
|
||||
} else if (command.equals("verack")) {
|
||||
|
@ -33,8 +33,15 @@ import java.util.Random;
|
||||
public class Ping extends BaseMessage {
|
||||
private long nonce;
|
||||
|
||||
public Ping(ByteBuffer payload) throws ProtocolException {
|
||||
super(payload);
|
||||
/**
|
||||
* Deserialize this message from a given payload.
|
||||
*
|
||||
* @param payload payload to deserialize from
|
||||
* @return read message
|
||||
* @throws BufferUnderflowException if the read message extends beyond the remaining bytes of the payload
|
||||
*/
|
||||
public static Ping read(ByteBuffer payload) throws BufferUnderflowException, ProtocolException {
|
||||
return new Ping(ByteUtils.readInt64(payload));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,7 +65,7 @@ public class Ping extends BaseMessage {
|
||||
|
||||
@Override
|
||||
protected void parse(ByteBuffer payload) throws BufferUnderflowException, ProtocolException {
|
||||
nonce = ByteUtils.readInt64(payload);
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** @deprecated returns true */
|
||||
|
Loading…
Reference in New Issue
Block a user