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.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_INV_SIZE
A hard coded constant in the protocol.
|
items, MAX_INVENTORY_ITEMS
cursor, length, MAX_SIZE, offset, params, payload, protocolVersion, recached, serializer, UNKNOWN_LENGTH
Constructor and Description |
---|
InventoryMessage(NetworkParameters params) |
InventoryMessage(NetworkParameters params,
byte[] bytes) |
InventoryMessage(NetworkParameters params,
byte[] payload,
MessageSerializer serializer,
int length)
Deserializes an 'inv' message.
|
Modifier and Type | Method and Description |
---|---|
void |
addBlock(Block block) |
void |
addTransaction(Transaction tx) |
static InventoryMessage |
with(Transaction... txns)
Creates a new inv message for the given transactions.
|
addItem, bitcoinSerializeToStream, equals, getItems, hashCode, parse, removeItem
adjustLength, bitcoinSerialize, bitcoinSerialize, getHash, getMessageSize, getParams, hasMoreBytes, isCached, isRecached, readByteArray, readBytes, readHash, readInt64, readStr, readUint32, readUint64, readVarInt, readVarInt, unCache, unsafeBitcoinSerialize
public static final int MAX_INV_SIZE
public InventoryMessage(NetworkParameters params, byte[] bytes) throws ProtocolException
ProtocolException
public InventoryMessage(NetworkParameters params, byte[] payload, MessageSerializer serializer, int length) throws ProtocolException
params
- NetworkParameters object.payload
- Bitcoin protocol formatted byte array containing message content.serializer
- the serializer to use for this message.length
- The length of message if known. Usually this is provided when deserializing of the wire
as the length will be provided as part of the header. If unknown then set to Message.UNKNOWN_LENGTHProtocolException
public InventoryMessage(NetworkParameters params)
public void addBlock(Block block)
public void addTransaction(Transaction tx)
public static InventoryMessage with(Transaction... txns)
Copyright © 2016. All rights reserved.