Package org.bitcoinj.core
Class FilteredBlock
- java.lang.Object
-
- org.bitcoinj.core.Message
-
- org.bitcoinj.core.FilteredBlock
-
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 aPartialMerkleTreewhich contains the transactions which matched the filter.Instances of this class are not safe for use by multiple threads.
-
-
Field Summary
-
Fields inherited from class org.bitcoinj.core.Message
cursor, length, MAX_SIZE, offset, params, payload, recached, serializer, UNKNOWN_LENGTH
-
-
Constructor Summary
Constructors Constructor Description FilteredBlock(NetworkParameters params, byte[] payloadBytes)FilteredBlock(NetworkParameters params, Block header, PartialMerkleTree pmt)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbitcoinSerializeToStream(java.io.OutputStream stream)Serializes this message to the provided stream.booleanequals(java.lang.Object o)java.util.Map<Sha256Hash,Transaction>getAssociatedTransactions()Gets the set of transactions which were provided using provideTransaction() which match in getTransactionHashes()BlockgetBlockHeader()Gets a copy of the block headerSha256HashgetHash()Gets the hash of the block represented in this Filtered BlockPartialMerkleTreegetPartialMerkleTree()Returns thePartialMerkleTreeobject that provides the mathematical proof of transaction inclusion in the block.intgetTransactionCount()Number of transactions in this block, before it was filteredjava.util.List<Sha256Hash>getTransactionHashes()Gets a list of leaf hashes which are contained in the partial merkle tree in this filtered blockinthashCode()protected voidparse()booleanprovideTransaction(Transaction tx)Provide this FilteredBlock with a transaction which is in its Merkle tree.java.lang.StringtoString()-
Methods inherited from class org.bitcoinj.core.Message
adjustLength, bitcoinSerialize, bitcoinSerialize, getMessageSize, getParams, hasMoreBytes, isCached, isRecached, readByte, readByteArray, readBytes, readHash, readInt64, readStr, readUint32, readUint64, readVarInt, readVarInt, setSerializer, unCache, unsafeBitcoinSerialize
-
-
-
-
Constructor Detail
-
FilteredBlock
public FilteredBlock(NetworkParameters params, byte[] payloadBytes) throws ProtocolException
- Throws:
ProtocolException
-
FilteredBlock
public FilteredBlock(NetworkParameters params, Block header, PartialMerkleTree pmt)
-
-
Method Detail
-
bitcoinSerializeToStream
public void bitcoinSerializeToStream(java.io.OutputStream stream) throws java.io.IOExceptionDescription copied from class:MessageSerializes this message to the provided stream. If you just want the raw bytes use bitcoinSerialize().- Overrides:
bitcoinSerializeToStreamin classMessage- Throws:
java.io.IOException
-
parse
protected void parse() throws ProtocolException- Specified by:
parsein classMessage- Throws:
ProtocolException
-
getTransactionHashes
public java.util.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 doesn't match the block headerVerificationException
-
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
-
provideTransaction
public boolean provideTransaction(Transaction tx) throws VerificationException
Provide this FilteredBlock with a transaction which is in its Merkle tree.- Returns:
- false if the tx is not relevant to this FilteredBlock
- Throws:
VerificationException
-
getPartialMerkleTree
public PartialMerkleTree getPartialMerkleTree()
Returns thePartialMerkleTreeobject that provides the mathematical proof of transaction inclusion in the block.
-
getAssociatedTransactions
public java.util.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
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-