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 intMAX_HEADERS- 
Fields inherited from class org.bitcoinj.core.Message
cursor, length, MAX_SIZE, offset, params, payload, recached, serializer, UNKNOWN_LENGTH 
 - 
 
- 
Constructor Summary
Constructors Constructor Description HeadersMessage(NetworkParameters params, byte[] 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 voidbitcoinSerializeToStream(java.io.OutputStream stream)Serializes this message to the provided stream.java.util.List<Block>getBlockHeaders()protected voidparse()- 
Methods inherited from class org.bitcoinj.core.Message
adjustLength, bitcoinSerialize, bitcoinSerialize, getHash, getMessageSize, getParams, hasMoreBytes, isCached, isRecached, readByte, readByteArray, readBytes, readHash, readInt64, readStr, readUint32, readUint64, readVarInt, readVarInt, setSerializer, unCache, unsafeBitcoinSerialize 
 - 
 
 - 
 
- 
- 
Field Detail
- 
MAX_HEADERS
public static final int MAX_HEADERS
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
HeadersMessage
public HeadersMessage(NetworkParameters params, byte[] 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.IOExceptionDescription copied from class:MessageSerializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Overrides:
 bitcoinSerializeToStreamin classMessage- Throws:
 java.io.IOException
 
- 
parse
protected void parse() throws ProtocolException- Specified by:
 parsein classMessage- Throws:
 ProtocolException
 
- 
getBlockHeaders
public java.util.List<Block> getBlockHeaders()
 
 - 
 
 -