com.google.bitcoin.core
Class FilteredBlock

java.lang.Object
  extended by com.google.bitcoin.core.Message
      extended by com.google.bitcoin.core.FilteredBlock
All Implemented Interfaces:
Serializable

public class FilteredBlock
extends Message

A FilteredBlock is used to relay a block with its transactions filtered using a BloomFilter. It consists of the block header and a PartialMerkleTree which contains the transactions which matched the filter.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.bitcoin.core.Message
Message.LazyParseException
 
Field Summary
static int MIN_PROTOCOL_VERSION
          The protocol version at which Bloom filtering started to be supported.
 
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
FilteredBlock(NetworkParameters params, byte[] payloadBytes)
           
 
Method Summary
 void bitcoinSerializeToStream(OutputStream stream)
          Serializes this message to the provided stream.
 Map<Sha256Hash,Transaction> getAssociatedTransactions()
          Gets the set of transactions which were provided using provideTransaction() which match in getTransactionHashes()
 Block getBlockHeader()
          Gets a copy of the block header
 Sha256Hash getHash()
          Gets the hash of the block represented in this Filtered Block
 int getTransactionCount()
          Number of transactions in this block, before it was filtered
 List<Sha256Hash> getTransactionHashes()
          Gets a list of leaf hashes which are contained in the partial merkle tree in this filtered block
protected  void parseLite()
          Perform the most minimal parse possible to calculate the length of the message.
 boolean provideTransaction(Transaction tx)
          Provide this FilteredBlock with a transaction which is in its merkle tree
 
Methods inherited from class com.google.bitcoin.core.Message
adjustLength, bitcoinSerialize, bitcoinSerialize, ensureParsed, getMessageSize, getParams, isCached, isParsed, isRecached, maybeParse, unCache, unsafeBitcoinSerialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_PROTOCOL_VERSION

public static final int MIN_PROTOCOL_VERSION
The protocol version at which Bloom filtering started to be supported.

See Also:
Constant Field Values
Constructor Detail

FilteredBlock

public FilteredBlock(NetworkParameters params,
                     byte[] payloadBytes)
              throws ProtocolException
Throws:
ProtocolException
Method Detail

bitcoinSerializeToStream

public void bitcoinSerializeToStream(OutputStream stream)
                              throws IOException
Description copied from class: Message
Serializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().

Throws:
IOException

parseLite

protected void parseLite()
                  throws ProtocolException
Description copied from class: Message
Perform the most minimal parse possible to calculate the length of the message. This is only required for subclasses of ChildClass as root level messages will have their length passed into the constructor.

Implementations should adhere to the following contract: If parseLazy = true the 'length' field must be set before returning. If parseLazy = false the length field must be set either within the parseLite() method OR the parse() method. The overriding requirement is that length must be set to non UNKNOWN_MESSAGE value by the time the constructor exits.

Specified by:
parseLite in class Message
Throws:
ProtocolException

getTransactionHashes

public List<Sha256Hash> getTransactionHashes()
                                      throws VerificationException
Gets a list of leaf hashes which are contained in the partial merkle tree in this filtered block

Throws:
ProtocolException - If the partial merkle block is invalid or the merkle root of the partial merkle block doesnt match the block header
VerificationException

getBlockHeader

public Block getBlockHeader()
Gets a copy of the block header


getHash

public Sha256Hash getHash()
Gets the hash of the block represented in this Filtered Block

Overrides:
getHash in class Message

provideTransaction

public boolean provideTransaction(Transaction tx)
                           throws VerificationException
Provide this FilteredBlock with a transaction which is in its merkle tree

Throws:
VerificationException

getAssociatedTransactions

public Map<Sha256Hash,Transaction> getAssociatedTransactions()
Gets the set of transactions which were provided using provideTransaction() which match in getTransactionHashes()


getTransactionCount

public int getTransactionCount()
Number of transactions in this block, before it was filtered



Copyright © 2014. All rights reserved.