Class InventoryMessage

  • All Implemented Interfaces:
    Message
    Direct Known Subclasses:
    NotFoundMessage

    public class InventoryMessage
    extends ListMessage

    Represents the "inv" P2P network message. An inv contains a list of hashes of either blocks or transactions. It's a bandwidth optimization - on receiving some data, a (fully validating) peer sends every connected peer an inv containing the hash of what it saw. It'll only transmit the full thing if a peer asks for it with a GetDataMessage.

    Instances of this class -- that use deprecated methods -- are not safe for use by multiple threads.

    • Field Detail

      • MAX_INV_SIZE

        public static final int MAX_INV_SIZE
        A hard coded constant in the protocol.
        See Also:
        Constant Field Values
    • Constructor Detail

      • InventoryMessage

        @Deprecated
        protected InventoryMessage()
        Deprecated.
      • InventoryMessage

        protected InventoryMessage​(java.util.List<InventoryItem> items)
    • Method Detail

      • read

        public static InventoryMessage 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
      • addBlock

        @Deprecated
        public void addBlock​(Block block)
        Deprecated.
        Use a constructor or factoring
      • addTransaction

        @Deprecated
        public void addTransaction​(Transaction tx)
        Deprecated.
        Use a constructor or factoring