Class GetBlocksMessage

  • All Implemented Interfaces:
    Message
    Direct Known Subclasses:
    GetHeadersMessage

    public class GetBlocksMessage
    extends BaseMessage

    Represents the "getblocks" P2P network message, which requests the hashes of the parts of the block chain we're missing. Those blocks can then be downloaded with a GetDataMessage.

    Instances of this class are not safe for use by multiple threads.

    • Constructor Detail

      • GetBlocksMessage

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

      • read

        public static GetBlocksMessage 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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • bitcoinSerializeToStream

        protected void bitcoinSerializeToStream​(java.io.OutputStream stream)
                                         throws java.io.IOException
        Description copied from class: BaseMessage
        Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().
        Specified by:
        bitcoinSerializeToStream in class BaseMessage
        Throws:
        java.io.IOException
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object