Package org.bitcoinj.core
Class HeadersMessage
- java.lang.Object
-
- org.bitcoinj.core.Message
-
- org.bitcoinj.core.HeadersMessage
-
public class HeadersMessage extends Message
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
-
Fields inherited from class org.bitcoinj.core.Message
MAX_SIZE, params, payload, serializer
-
-
Constructor Summary
Constructors Constructor Description HeadersMessage(NetworkParameters params, java.nio.ByteBuffer payload)
HeadersMessage(NetworkParameters params, java.util.List<Block> headers)
HeadersMessage(NetworkParameters params, Block... headers)
-
Method Summary
All 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()
protected void
parse()
-
Methods inherited from class org.bitcoinj.core.Message
bitcoinSerialize, getHash, getMessageSize, getParams, readByte, readByteArray, readBytes, readHash, readInt32, readInt64, readStr, readUint32, readUint64, readVarInt, skipBytes, unCache, unsafeBitcoinSerialize
-
-
-
-
Field Detail
-
MAX_HEADERS
public static final int MAX_HEADERS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HeadersMessage
public HeadersMessage(NetworkParameters params, java.nio.ByteBuffer payload) throws ProtocolException
- Throws:
ProtocolException
-
HeadersMessage
public HeadersMessage(NetworkParameters params, Block... headers) throws ProtocolException
- Throws:
ProtocolException
-
HeadersMessage
public HeadersMessage(NetworkParameters params, java.util.List<Block> headers) throws ProtocolException
- Throws:
ProtocolException
-
-
Method Detail
-
bitcoinSerializeToStream
public void bitcoinSerializeToStream(java.io.OutputStream stream) throws java.io.IOException
Description copied from class:Message
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Overrides:
bitcoinSerializeToStream
in classMessage
- Throws:
java.io.IOException
-
parse
protected void parse() throws java.nio.BufferUnderflowException, ProtocolException
- Specified by:
parse
in classMessage
- Throws:
java.nio.BufferUnderflowException
ProtocolException
-
getBlockHeaders
public java.util.List<Block> getBlockHeaders()
-
-