Class GetHeadersMessage

  • All Implemented Interfaces:
    Message

    public class GetHeadersMessage
    extends GetBlocksMessage

    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.

    • Constructor Detail

      • GetHeadersMessage

        public GetHeadersMessage​(long protocolVersion,
                                 BlockLocator locator,
                                 Sha256Hash stopHash)
    • Method Detail

      • read

        public static GetHeadersMessage 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 payload
        ProtocolException
      • equals

        public boolean equals​(java.lang.Object o)
        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 class GetBlocksMessage