Package org.bitcoinj.core
Class InventoryMessage
- java.lang.Object
-
- org.bitcoinj.core.Message
-
- org.bitcoinj.core.ListMessage
-
- org.bitcoinj.core.InventoryMessage
-
- 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 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
-
Fields inherited from class org.bitcoinj.core.Message
MAX_SIZE, params, payload, serializer
-
-
Constructor Summary
Constructors Constructor Description InventoryMessage(NetworkParameters params)
InventoryMessage(NetworkParameters params, java.nio.ByteBuffer payload)
InventoryMessage(NetworkParameters params, java.nio.ByteBuffer payload, MessageSerializer serializer)
Deserializes an 'inv' message.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBlock(Block block)
void
addTransaction(Transaction tx)
static InventoryMessage
with(Transaction... txns)
Creates a new inv message for the given transactions.-
Methods inherited from class org.bitcoinj.core.ListMessage
addItem, bitcoinSerializeToStream, equals, getItems, hashCode, parse, removeItem, toString
-
Methods inherited from class org.bitcoinj.core.Message
bitcoinSerialize, getHash, getMessageSize, getParams, readByte, readByteArray, readBytes, readHash, readInt32, readInt64, readStr, readUint32, readUint64, readVarInt, skipBytes, unCache, 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
public InventoryMessage(NetworkParameters params, java.nio.ByteBuffer payload) throws ProtocolException
- Throws:
ProtocolException
-
InventoryMessage
public InventoryMessage(NetworkParameters params, java.nio.ByteBuffer payload, MessageSerializer serializer) throws ProtocolException
Deserializes an 'inv' message.- Parameters:
params
- NetworkParameters object.payload
- Bitcoin protocol formatted byte array containing message content.serializer
- the serializer to use for this message.- Throws:
ProtocolException
-
InventoryMessage
public InventoryMessage(NetworkParameters params)
-
-
Method Detail
-
addBlock
public void addBlock(Block block)
-
addTransaction
public void addTransaction(Transaction tx)
-
with
public static InventoryMessage with(Transaction... txns)
Creates a new inv message for the given transactions.
-
-