net.tomp2p.rpc
Class DigestInfo

java.lang.Object
  extended by net.tomp2p.rpc.DigestInfo

public class DigestInfo
extends Object

Calculates or sets a global hash. The digest is used in two places: for routing, where a message needs to have a predictable size. Thus in this case a global hash is calculated. The second usage is get() for getting a list of hashes from peers. Here we don't need to restrict ourself, since we use TCP.

Author:
Thomas Bocek

Constructor Summary
DigestInfo()
          Empty constructor is used to add the hashes to the list.
DigestInfo(int size)
          Create a digest with the size only.
DigestInfo(Number160 keyDigest, Number160 contentDigest, int size)
          If a global hash has already been calculated, then this constructor is used to store those.
 
Method Summary
 boolean equals(Object obj)
           
 SimpleBloomFilter<Number160> getContentBloomFilter(int bitArraySize, int expectedElements)
           
 Number160 getContentDigest()
           
 Map<Number160,Number160> getDigests()
           
 SimpleBloomFilter<Number160> getKeyBloomFilter(int bitArraySize, int expectedElements)
           
 Number160 getKeyDigest()
           
 int getSize()
           
 int hashCode()
           
 boolean isEmpty()
           
 void put(Number160 key, Number160 content)
          Stores a key and the hash of the content for further processing
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigestInfo

public DigestInfo()
Empty constructor is used to add the hashes to the list.


DigestInfo

public DigestInfo(int size)
Create a digest with the size only.

Parameters:
size -

DigestInfo

public DigestInfo(Number160 keyDigest,
                  Number160 contentDigest,
                  int size)
If a global hash has already been calculated, then this constructor is used to store those. Note that once a global hash is set it cannot be unset.

Parameters:
keyDigest -
contentDigest -
size -
Method Detail

getKeyDigest

public Number160 getKeyDigest()
Returns:
Returns or calculates the global key hash. The global key hash will be calculated if the empty constructor is used.

getContentDigest

public Number160 getContentDigest()
Returns:
Returns or calculates the global content hash. The global content hash will be calculated if the empty constructor is used.

getKeyBloomFilter

public SimpleBloomFilter<Number160> getKeyBloomFilter(int bitArraySize,
                                                      int expectedElements)

getContentBloomFilter

public SimpleBloomFilter<Number160> getContentBloomFilter(int bitArraySize,
                                                          int expectedElements)

put

public void put(Number160 key,
                Number160 content)
Stores a key and the hash of the content for further processing

Parameters:
key - The key of the content
content - The hash of the content

getDigests

public Map<Number160,Number160> getDigests()
Returns:
The list of hashes

getSize

public int getSize()
Returns:
The number of hashes

isEmpty

public boolean isEmpty()
Returns:
True is the digest information has not been provided.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2013. All Rights Reserved.