Package org.bitcoinj.core
Class GetHeadersMessage
java.lang.Object
org.bitcoinj.core.BaseMessage
org.bitcoinj.core.GetBlocksMessage
org.bitcoinj.core.GetHeadersMessage
- All Implemented Interfaces:
Message
The "getheaders" command is structurally identical to "getblocks", but has different meaning. On receiving this message a Bitcoin node returns matching blocks up to the limit, but without the bodies. It is useful as an optimization: when your wallet does not contain any keys created before a particular time, you don't have to download the bodies for those blocks because you know there are no relevant transactions.
Instances of this class are not safe for use by multiple threads.
-
Field Summary
Fields inherited from class org.bitcoinj.core.GetBlocksMessage
locator, stopHash, version
-
Constructor Summary
ConstructorDescriptionGetHeadersMessage
(long protocolVersion, BlockLocator locator, Sha256Hash stopHash) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares two getheaders messages.int
hashCode()
static GetHeadersMessage
read
(ByteBuffer payload) Deserialize this message from a given payload.toString()
Methods inherited from class org.bitcoinj.core.GetBlocksMessage
bitcoinSerializeToStream, getLocator, getStopHash
Methods inherited from class org.bitcoinj.core.BaseMessage
messageSize, serialize
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.bitcoinj.core.Message
bitcoinSerialize, getMessageSize, unsafeBitcoinSerialize
-
Constructor Details
-
GetHeadersMessage
-
-
Method Details
-
read
public static GetHeadersMessage read(ByteBuffer payload) throws BufferUnderflowException, ProtocolException 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
-
toString
- Overrides:
toString
in classGetBlocksMessage
-
equals
Compares two getheaders messages. Note that even though they are structurally identical a GetHeadersMessage will not compare equal to a GetBlocksMessage containing the same data.- Overrides:
equals
in classGetBlocksMessage
-
hashCode
public int hashCode()- Overrides:
hashCode
in classGetBlocksMessage
-