Package org.bitcoinj.core
Class Ping
- java.lang.Object
-
- org.bitcoinj.core.BaseMessage
-
- org.bitcoinj.core.Ping
-
- All Implemented Interfaces:
Message
public class Ping extends BaseMessage
See BIP31 for details.Instances of this class are immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidbitcoinSerializeToStream(java.io.OutputStream stream)Serializes this message to the provided stream.booleanhasNonce()Deprecated.returns truelongnonce()static Pingof(long nonce)Create a ping with a nonce value.Pongpong()Create aPongreply to this ping.static Pingrandom()Create a ping with a random nonce value.static Pingread(java.nio.ByteBuffer payload)Deserialize this message from a given payload.-
Methods inherited from class org.bitcoinj.core.BaseMessage
messageSize, serialize
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bitcoinj.core.Message
bitcoinSerialize, getMessageSize, unsafeBitcoinSerialize
-
-
-
-
Method Detail
-
read
public static Ping read(java.nio.ByteBuffer payload) throws java.nio.BufferUnderflowException, ProtocolException
Deserialize this message from a given payload.- Parameters:
payload- payload to deserialize from- Returns:
- read message
- Throws:
java.nio.BufferUnderflowException- if the read message extends beyond the remaining bytes of the payloadProtocolException
-
of
public static Ping of(long nonce)
Create a ping with a nonce value. Only use this if the remote node has a protocol version greater than 60000- Parameters:
nonce- nonce value- Returns:
- ping message
-
random
public static Ping random()
Create a ping with a random nonce value. Only use this if the remote node has a protocol version greater than 60000- Returns:
- ping message
-
bitcoinSerializeToStream
public void bitcoinSerializeToStream(java.io.OutputStream stream) throws java.io.IOExceptionDescription copied from class:BaseMessageSerializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Specified by:
bitcoinSerializeToStreamin classBaseMessage- Throws:
java.io.IOException
-
hasNonce
@Deprecated public boolean hasNonce()
Deprecated.returns true
-
nonce
public long nonce()
-
-