mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-18 21:32:35 +01:00
Pong: move parse()
to static constructor read()
This commit is contained in:
parent
1f8ed23e24
commit
14ba406298
@ -242,7 +242,7 @@ public class BitcoinSerializer extends MessageSerializer {
|
||||
} else if (command.equals("ping")) {
|
||||
return Ping.read(payload);
|
||||
} else if (command.equals("pong")) {
|
||||
return new Pong(payload);
|
||||
return Pong.read(payload);
|
||||
} else if (command.equals("verack")) {
|
||||
check(!payload.hasRemaining(), ProtocolException::new);
|
||||
return new VersionAck();
|
||||
|
@ -32,8 +32,15 @@ import java.nio.ByteBuffer;
|
||||
public class Pong extends BaseMessage {
|
||||
private long nonce;
|
||||
|
||||
public Pong(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 Pong read(ByteBuffer payload) throws BufferUnderflowException, ProtocolException {
|
||||
return new Pong(ByteUtils.readInt64(payload));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +53,7 @@ public class Pong extends BaseMessage {
|
||||
|
||||
@Override
|
||||
protected void parse(ByteBuffer payload) throws BufferUnderflowException, ProtocolException {
|
||||
nonce = ByteUtils.readInt64(payload);
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user