com.google.bitcoin.core
Class HeadersMessage

java.lang.Object
  extended by com.google.bitcoin.core.Message
      extended by com.google.bitcoin.core.HeadersMessage
All Implemented Interfaces:
Serializable

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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.bitcoin.core.Message
Message.LazyParseException
 
Field Summary
static int MAX_HEADERS
           
 
Fields inherited from class com.google.bitcoin.core.Message
bytes, checksum, cursor, length, MAX_SIZE, offset, params, parsed, parseLazy, parseRetain, protocolVersion, recached, UNKNOWN_LENGTH
 
Constructor Summary
HeadersMessage(NetworkParameters params, Block... headers)
           
HeadersMessage(NetworkParameters params, byte[] payload)
           
 
Method Summary
 void bitcoinSerializeToStream(OutputStream stream)
          Serializes this message to the provided stream.
 List<Block> getBlockHeaders()
           
protected  void parseLite()
          Perform the most minimal parse possible to calculate the length of the message.
 
Methods inherited from class com.google.bitcoin.core.Message
adjustLength, bitcoinSerialize, bitcoinSerialize, ensureParsed, getHash, getMessageSize, getParams, isCached, isParsed, isRecached, maybeParse, unCache, unsafeBitcoinSerialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Method Detail

bitcoinSerializeToStream

public void bitcoinSerializeToStream(OutputStream stream)
                              throws IOException
Description copied from class: Message
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().

Throws:
IOException

parseLite

protected void parseLite()
                  throws ProtocolException
Description copied from class: Message
Perform the most minimal parse possible to calculate the length of the message. This is only required for subclasses of ChildClass as root level messages will have their length passed into the constructor.

Implementations should adhere to the following contract: If parseLazy = true the 'length' field must be set before returning. If parseLazy = false the length field must be set either within the parseLite() method OR the parse() method. The overriding requirement is that length must be set to non UNKNOWN_MESSAGE value by the time the constructor exits.

Specified by:
parseLite in class Message
Throws:
ProtocolException

getBlockHeaders

public List<Block> getBlockHeaders()


Copyright © 2014. All rights reserved.