Package org.bitcoinj.core
Class HeadersMessage
- java.lang.Object
-
- org.bitcoinj.core.BaseMessage
-
- org.bitcoinj.core.HeadersMessage
-
- All Implemented Interfaces:
Message
public class HeadersMessage extends BaseMessage
A protocol message that contains a repeated series of block headers, sent in response to the "getheaders" command. This is useful when you want to traverse the chain but know you don't care about the block contents, for example, because you have a freshly created wallet with no keys.
Instances of this class are not safe for use by multiple threads.
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_HEADERS
-
Constructor Summary
Constructors Constructor Description HeadersMessage(java.util.List<Block> headers)
HeadersMessage(Block... headers)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bitcoinSerializeToStream(java.io.OutputStream stream)
Serializes this message to the provided stream.java.util.List<Block>
getBlockHeaders()
static HeadersMessage
read(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
-
-
-
-
Field Detail
-
MAX_HEADERS
public static final int MAX_HEADERS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HeadersMessage
public HeadersMessage(Block... headers) throws ProtocolException
- Throws:
ProtocolException
-
HeadersMessage
public HeadersMessage(java.util.List<Block> headers) throws ProtocolException
- Throws:
ProtocolException
-
-
Method Detail
-
read
public static HeadersMessage 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
-
bitcoinSerializeToStream
public void bitcoinSerializeToStream(java.io.OutputStream stream) throws java.io.IOException
Description copied from class:BaseMessage
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Specified by:
bitcoinSerializeToStream
in classBaseMessage
- Throws:
java.io.IOException
-
getBlockHeaders
public java.util.List<Block> getBlockHeaders()
-
-