Class BloomFilter

java.lang.Object
com.norswap.nanoeth.receipts.BloomFilter
All Implemented Interfaces:
RLPLayoutable

@Wrapper
public final class BloomFilter
extends Object
implements RLPLayoutable
A bloom filter associated with one or multiple LogEntry.

In practice, such a bloom filter is constructed from all the log entries in a block, and included in the block header as BlockHeader.logsBloom.

See LogTopic for an explanation of the usefulness of bloom filters.

  • Field Details

    • bits

      public final byte[] bits
      The bytes making up the hash.
  • Constructor Details

    • BloomFilter

      public BloomFilter()
      Creates a new empty bloom filter.
    • BloomFilter

      public BloomFilter​(@Retained byte[] bits)
    • BloomFilter

      public BloomFilter​(String hexString)
      Creates a bloom filter from a hex string (e.g. 0x123).

      If the post-0x part of the hex string is not 512 characters long, the hash will be padded with zeroes at the start so that it is 256 bytes long.

  • Method Details

    • parse

      public static BloomFilter parse​(RLP rlp) throws RLPParsingException
      Throws:
      RLPParsingException
    • mayContain

      public boolean mayContain​(LogTopic topic)
      Indicates if some of the log entries associated to this bloom filter may contain the given topic.

      This can return true if the no log entries contains the topic, but may not return false if the some log entry contains the topic.

    • mayContain

      public boolean mayContain​(Address address)
      Indicates if the log entries associated to this bloom filter may have been been logged by the given address.

      This can return true if no log entry was logged by the address, but may not return false if some log entry was logged by the address.

    • toHexString

      public String toHexString()
      The hex-string representation of this hash, including leading 0 if any, as per ByteUtils.toFullHexString(byte[]).
    • rlpLayout

      public RLP rlpLayout()
      Description copied from interface: RLPLayoutable
      Returns the RLP layout for the object.
      Specified by:
      rlpLayout in interface RLPLayoutable
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object