com.google.bitcoin.core
Class InventoryMessage

java.lang.Object
  extended by com.google.bitcoin.core.Message
      extended by com.google.bitcoin.core.ListMessage
          extended by com.google.bitcoin.core.InventoryMessage
All Implemented Interfaces:
Serializable
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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.bitcoin.core.Message
Message.LazyParseException
 
Field Summary
 
Fields inherited from class com.google.bitcoin.core.ListMessage
items, MAX_INVENTORY_ITEMS
 
Fields inherited from class com.google.bitcoin.core.Message
bytes, checksum, cursor, length, MAX_SIZE, offset, params, parsed, parseLazy, parseRetain, protocolVersion, recached, UNKNOWN_LENGTH
 
Constructor Summary
InventoryMessage(NetworkParameters params)
           
InventoryMessage(NetworkParameters params, byte[] bytes)
           
InventoryMessage(NetworkParameters params, byte[] msg, boolean parseLazy, boolean parseRetain, int length)
          Deserializes an 'inv' message.
 
Method Summary
 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 com.google.bitcoin.core.ListMessage
addItem, bitcoinSerializeToStream, equals, getItems, parse, parseLite, removeItem
 
Methods inherited from class com.google.bitcoin.core.Message
adjustLength, bitcoinSerialize, bitcoinSerialize, ensureParsed, getHash, getMessageSize, getParams, isCached, isParsed, isRecached, maybeParse, unCache, unsafeBitcoinSerialize
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InventoryMessage

public InventoryMessage(NetworkParameters params,
                        byte[] bytes)
                 throws ProtocolException
Throws:
ProtocolException

InventoryMessage

public InventoryMessage(NetworkParameters params,
                        byte[] msg,
                        boolean parseLazy,
                        boolean parseRetain,
                        int length)
                 throws ProtocolException
Deserializes an 'inv' message.

Parameters:
params - NetworkParameters object.
msg - Bitcoin protocol formatted byte array containing message content.
parseLazy - Whether to perform a full parse immediately or delay until a read is requested.
parseRetain - Whether to retain the backing byte array for quick reserialization. If true and the backing byte array is invalidated due to modification of a field then the cached bytes may be repopulated and retained if the message is serialized again in the future.
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_LENGTH
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.



Copyright © 2014. All rights reserved.