Package org.bitcoinj.core
Class Ping
java.lang.Object
org.bitcoinj.core.BaseMessage
org.bitcoinj.core.Ping
- All Implemented Interfaces:
Message
See BIP31 for details.
Instances of this class are immutable.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bitcoinSerializeToStream
(OutputStream stream) Serializes this message to the provided stream.boolean
hasNonce()
Deprecated.returns truelong
nonce()
static Ping
of
(long nonce) Create a ping with a nonce value.pong()
Create aPong
reply to this ping.static Ping
random()
Create a ping with a random nonce value.static Ping
read
(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 Details
-
read
Deserialize this message from a given payload.- Parameters:
payload
- payload to deserialize from- Returns:
- read message
- Throws:
BufferUnderflowException
- if the read message extends beyond the remaining bytes of the payloadProtocolException
-
of
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
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
Description copied from class:BaseMessage
Serializes this message to the provided stream. If you just want the raw bytes useBaseMessage.serialize()
.- Specified by:
bitcoinSerializeToStream
in classBaseMessage
- Throws:
IOException
-
hasNonce
Deprecated.returns true -
nonce
public long nonce() -
pong
Create aPong
reply to this ping.- Returns:
- pong message
-