Package org.bitcoinj.core
Class InventoryMessage
- java.lang.Object
-
- org.bitcoinj.core.BaseMessage
-
- org.bitcoinj.core.ListMessage
-
- org.bitcoinj.core.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 Summary
Fields Modifier and Type Field Description static int
MAX_INV_SIZE
A hard coded constant in the protocol.-
Fields inherited from class org.bitcoinj.core.ListMessage
items, MAX_INVENTORY_ITEMS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
InventoryMessage()
Deprecated.protected
InventoryMessage(java.util.List<InventoryItem> items)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addBlock(Block block)
Deprecated.Use a constructor or factoringvoid
addTransaction(Transaction tx)
Deprecated.Use a constructor or factoringstatic InventoryMessage
ofBlocks(java.util.List<Block> blocks)
static InventoryMessage
ofBlocks(Block... blocks)
static InventoryMessage
ofTransactions(java.util.List<Transaction> transactions)
static InventoryMessage
ofTransactions(Transaction... transactions)
static InventoryMessage
read(java.nio.ByteBuffer payload)
Deserialize this message from a given payload.static InventoryMessage
with(Transaction... txns)
Deprecated.-
Methods inherited from class org.bitcoinj.core.ListMessage
addItem, bitcoinSerializeToStream, equals, getItems, hashCode, readItems, removeItem, toString
-
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
-
-
-
-
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 payloadProtocolException
-
ofBlocks
public static InventoryMessage ofBlocks(java.util.List<Block> blocks)
-
ofBlocks
public static InventoryMessage ofBlocks(Block... blocks)
-
ofTransactions
public static InventoryMessage ofTransactions(java.util.List<Transaction> transactions)
-
ofTransactions
public static InventoryMessage ofTransactions(Transaction... transactions)
-
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
-
with
@Deprecated public static InventoryMessage with(Transaction... txns)
Deprecated.Creates a new inv message for the given transactions.
-
-